Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore the prefix on output from npm version <inc> #2718

Merged
merged 1 commit into from Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/version.js
Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion test/lib/version.js
Expand Up @@ -6,6 +6,7 @@ let result = []
const noop = () => null
const npm = {
flatOptions: {
tagVersionPrefix: 'v',
json: false,
},
prefix: '',
Expand Down Expand Up @@ -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()
})
})