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:
authorisaacs <i@izs.me>2018-12-11 01:51:38 +0300
committerKat Marchán <kzm@zkat.tech>2018-12-11 01:51:38 +0300
commit02c837e01a71a26f37cbd5a09be89df8a9ce01da (patch)
tree8d4f53868dfa264fbfa649c54f8b369ece00b542
parent890a74458dd4a55e2d85f3eba9dbf125affa4206 (diff)
dist-tag: make 'ls' the default action (#106)
I keep typing `npm dist-tags` expecting it to print out a list of dist-tags and instead it yells at me and that feels very un-npm-y. PR-URL: https://github.com/npm/cli/pull/106 Credit: @isaacs Reviewed-By: @zkat
-rw-r--r--doc/cli/npm-dist-tag.md2
-rw-r--r--lib/dist-tag.js2
-rw-r--r--test/tap/dist-tag.js45
3 files changed, 48 insertions, 1 deletions
diff --git a/doc/cli/npm-dist-tag.md b/doc/cli/npm-dist-tag.md
index 1a69d1b6c..7de3c828f 100644
--- a/doc/cli/npm-dist-tag.md
+++ b/doc/cli/npm-dist-tag.md
@@ -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:
diff --git a/lib/dist-tag.js b/lib/dist-tag.js
index bd0c5ae8a..534cbe94c 100644
--- a/lib/dist-tag.js
+++ b/lib/dist-tag.js
@@ -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)
}
}
diff --git a/test/tap/dist-tag.js b/test/tap/dist-tag.js
index 651639f32..3631a598e 100644
--- a/test/tap/dist-tag.js
+++ b/test/tap/dist-tag.js
@@ -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' })
@@ -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(
[
@@ -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(
[