From 1fd5e181edc898187ff1e1be4fd715fa87d43bf0 Mon Sep 17 00:00:00 2001 From: Daniel Stockman Date: Tue, 15 Oct 2019 16:40:55 -0700 Subject: [PATCH] fix(npm-dist-tag): Respect `npm_config_dry_run` env var --- utils/npm-dist-tag/npm-dist-tag.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/npm-dist-tag/npm-dist-tag.js b/utils/npm-dist-tag/npm-dist-tag.js index 748f7a4c02..1066123ea0 100644 --- a/utils/npm-dist-tag/npm-dist-tag.js +++ b/utils/npm-dist-tag/npm-dist-tag.js @@ -12,6 +12,8 @@ exports.list = list; const DistTagConfig = figgyPudding( { + "dry-run": { default: false }, + dryRun: "dry-run", log: { default: log }, spec: {}, tag: {}, @@ -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}`); @@ -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]; @@ -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); }