Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2021-02-18 01:35:29 +0300
committernlf <quitlahok@gmail.com>2021-02-18 23:52:58 +0300
commit00afa316195f2db903146110a07ffdaec9bb6aa2 (patch)
tree084778fa19ee4c8ab1274ad053051bd5bc034732
parentaf4422cdbc110f93203667efc08b16f7aa74ac2f (diff)
restore the prefix on output from `npm version <inc>`nlf/restore-tag-prefix-on-version
PR-URL: https://github.com/npm/cli/pull/2718 Credit: @nlf Close: #2718 Reviewed-by: @wraithgar
-rw-r--r--lib/version.js14
-rw-r--r--test/lib/version.js6
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/version.js b/lib/version.js
index a96f5d605..3a46efae1 100644
--- a/lib/version.js
+++ b/lib/version.js
@@ -37,15 +37,21 @@ const version = async args => {
case 0:
return list()
case 1:
- return output(await libversion(args[0], {
- ...npm.flatOptions,
- path: npm.prefix,
- }))
+ return version_(args)
default:
throw usage
}
}
+const version_ = async (args) => {
+ const prefix = npm.flatOptions.tagVersionPrefix
+ const version = await libversion(args[0], {
+ ...npm.flatOptions,
+ path: npm.prefix,
+ })
+ return output(`${prefix}${version}`)
+}
+
const list = async () => {
const results = {}
const { promisify } = require('util')
diff --git a/test/lib/version.js b/test/lib/version.js
index f36132253..943e14370 100644
--- a/test/lib/version.js
+++ b/test/lib/version.js
@@ -6,6 +6,7 @@ let result = []
const noop = () => null
const npm = {
flatOptions: {
+ tagVersionPrefix: 'v',
json: false,
},
prefix: '',
@@ -144,17 +145,20 @@ t.test('with one arg', t => {
t.deepEqual(
opts,
{
+ tagVersionPrefix: 'v',
json: false,
path: '',
},
'should forward expected options'
)
- t.end()
+ return '4.0.0'
},
})
version(['major'], err => {
if (err)
throw err
+ t.same(result, ['v4.0.0'], 'outputs the new version prefixed by the tagVersionPrefix')
+ t.end()
})
})