Skip to content

Commit

Permalink
fix(npm-dist-tag): Respect npm_config_dry_run env var
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Oct 15, 2019
1 parent 5a1d229 commit 1fd5e18
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions utils/npm-dist-tag/npm-dist-tag.js
Expand Up @@ -12,6 +12,8 @@ exports.list = list;

const DistTagConfig = figgyPudding(
{
"dry-run": { default: false },
dryRun: "dry-run",
log: { default: log },
spec: {},
tag: {},
Expand All @@ -35,6 +37,12 @@ function add(spec, tag, _opts, otpCache) {

opts.log.verbose("dist-tag", `adding "${cleanTag}" to ${name}@${version}`);

// istanbul ignore next
if (opts.dryRun) {
opts.log.silly("dist-tag", "dry-run configured, bailing now");
return Promise.resolve();
}

return fetchTags(opts).then(tags => {
if (tags[cleanTag] === version) {
opts.log.warn("dist-tag", `${name}@${cleanTag} already set to ${version}`);
Expand Down Expand Up @@ -72,6 +80,12 @@ function remove(spec, tag, _opts, otpCache) {

opts.log.verbose("dist-tag", `removing "${tag}" from ${opts.spec.name}`);

// istanbul ignore next
if (opts.dryRun) {
opts.log.silly("dist-tag", "dry-run configured, bailing now");
return Promise.resolve();
}

return fetchTags(opts).then(tags => {
const version = tags[tag];

Expand Down Expand Up @@ -103,6 +117,12 @@ function list(spec, _opts) {
spec: npa(spec),
});

// istanbul ignore next
if (opts.dryRun) {
opts.log.silly("dist-tag", "dry-run configured, bailing now");
return Promise.resolve();
}

return fetchTags(opts);
}

Expand Down

0 comments on commit 1fd5e18

Please sign in to comment.