feat(last-release): add custom dist-tag
This commit is contained in:
parent
6cf1711151
commit
dbea5cc1b1
16
src/index.js
16
src/index.js
@ -69,13 +69,17 @@ npmconf.load({}, (err, conf) => {
|
||||
|
||||
if (wroteNpmRc) log.verbose(PREFIX, 'Wrote authToken to .npmrc.')
|
||||
|
||||
require('./pre')(pkg, {
|
||||
const npmConfig = {
|
||||
auth: {
|
||||
token: env.NPM_TOKEN
|
||||
},
|
||||
loglevel: log.level,
|
||||
registry: registry + (registry[registry.length - 1] !== '/' ? '/' : '')
|
||||
},
|
||||
registry: registry + (registry[registry.length - 1] !== '/' ? '/' : ''),
|
||||
tag: (pkg.publishConfig || {}).tag || conf.get('tag') || 'latest'
|
||||
}
|
||||
|
||||
require('./pre')(pkg,
|
||||
npmConfig,
|
||||
plugins,
|
||||
(err, release) => {
|
||||
if (err) {
|
||||
@ -87,10 +91,12 @@ npmconf.load({}, (err, conf) => {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
log.verbose(PREFIX, `Determined version ${release.version}.`)
|
||||
const message = `Determined version ${release.version} as "${npmConfig.tag}".`
|
||||
|
||||
log.verbose(PREFIX, message)
|
||||
|
||||
if (options.debug) {
|
||||
log.error(PREFIX, `Determined version ${release.version}, but not publishing in debug mode.`, release)
|
||||
log.error(PREFIX, `${message} Not publishing in debug mode.`, release)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
const SemanticReleaseError = require('@semantic-release/error')
|
||||
|
||||
const npmlog = require('npmlog')
|
||||
const RegClient = require('npm-registry-client')
|
||||
|
||||
@ -11,11 +13,14 @@ module.exports = function (pkg, npmConfig, cb) {
|
||||
if (err && err.statusCode === 404) return cb(null, {})
|
||||
if (err) return cb(err)
|
||||
|
||||
const version = data['dist-tags'].latest
|
||||
const version = data['dist-tags'][npmConfig.tag]
|
||||
|
||||
if (!version) return cb(new SemanticReleaseError(`There is no release with the dist-tag "${npmConfig.tag}" yet. Tag a version first.`, 'ENODISTTAG'))
|
||||
|
||||
cb(null, {
|
||||
version,
|
||||
gitHead: data.versions[version].gitHead
|
||||
gitHead: data.versions[version].gitHead,
|
||||
tag: npmConfig.tag
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user