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

dist-tag: make 'ls' the default action #106

Merged
merged 1 commit into from
Dec 10, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/cli/npm-dist-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Add, remove, and enumerate distribution tags on a package:
Show all of the dist-tags for a package, defaulting to the package in
the current prefix.

This is the default action if none is specified.

A tag can be used when installing packages as a reference to a version instead
of using a specific version number:

Expand Down
2 changes: 1 addition & 1 deletion lib/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function distTag (args, cb) {
case 'ls': case 'l': case 'sl': case 'list':
return list(args[0], cb)
default:
return cb('Usage:\n' + distTag.usage)
return list(cmd, cb)
}
}

Expand Down
45 changes: 45 additions & 0 deletions test/tap/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ function mocks (server) {
server.get('/-/package/@scoped%2fpkg/dist-tags')
.reply(200, { latest: '1.0.0', a: '0.0.1', b: '0.5.0' })

server.get('/-/package/@scoped%2fpkg/dist-tags')
.reply(200, { latest: '1.0.0', a: '0.0.1', b: '0.5.0' })

// ls named package
server.get('/-/package/@scoped%2fanother/dist-tags')
.reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' })

server.get('/-/package/@scoped%2fanother/dist-tags')
.reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' })

// add c
server.get('/-/package/@scoped%2fanother/dist-tags')
.reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' })
Expand Down Expand Up @@ -83,6 +89,25 @@ test('npm dist-tags ls in current package', function (t) {
)
})

test('npm dist-tags ls default in current package', function (t) {
common.npm(
[
'dist-tags',
'--registry', common.registry,
'--loglevel', 'silent'
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.notOk(code, 'exited OK')
t.notOk(stderr, 'no error output')
t.equal(stdout, 'a: 0.0.1\nb: 0.5.0\nlatest: 1.0.0\n')

t.end()
}
)
})

test('npm dist-tags ls on named package', function (t) {
common.npm(
[
Expand All @@ -103,6 +128,26 @@ test('npm dist-tags ls on named package', function (t) {
)
})

test('npm dist-tags ls default, named package', function (t) {
common.npm(
[
'dist-tags',
'@scoped/another',
'--registry', common.registry,
'--loglevel', 'silent'
],
{ cwd: pkg },
function (er, code, stdout, stderr) {
t.ifError(er, 'npm access')
t.notOk(code, 'exited OK')
t.notOk(stderr, 'no error output')
t.equal(stdout, 'a: 0.0.2\nb: 0.6.0\nlatest: 2.0.0\n')

t.end()
}
)
})

test('npm dist-tags add @scoped/another@7.7.7 c', function (t) {
common.npm(
[
Expand Down