forked from semantic-release/semantic-release
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(getLastRelease): Move getLastRelease to plugin. Remove npm tag
Move getLastRelease into it's very own plugin (@semantic-release/last-release-npm), which this project now depends on. BREAKING CHANGE: Remove npmTag from output of getLastRelease. It wasn't used anywhere. Refs semantic-release#56, semantic-release#51
- Loading branch information
Showing
4 changed files
with
34 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,5 @@ | ||
const SemanticReleaseError = require('@semantic-release/error') | ||
module.exports = function (config, cb) { | ||
const {plugins} = config | ||
|
||
const npmlog = require('npmlog') | ||
const RegClient = require('npm-registry-client') | ||
|
||
module.exports = function ({pkg, npm}, cb) { | ||
npmlog.level = npm.loglevel || 'error' | ||
const client = new RegClient({log: npmlog}) | ||
|
||
client.get(`${npm.registry}${pkg.name.replace('/', '%2F')}`, { | ||
auth: npm.auth | ||
}, (err, data) => { | ||
if (err && err.statusCode === 404) return cb(null, {}) | ||
if (err) return cb(err) | ||
|
||
const version = data['dist-tags'][npm.tag] | ||
|
||
if (!version) return cb(new SemanticReleaseError(`There is no release with the dist-tag "${npm.tag}" yet. Tag a version first.`, 'ENODISTTAG')) | ||
|
||
cb(null, { | ||
version, | ||
gitHead: data.versions[version].gitHead, | ||
tag: npm.tag | ||
}) | ||
}) | ||
plugins.getLastRelease(config, cb) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters