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:
-rw-r--r--lib/ls.js2
-rw-r--r--test/tap/ls-depth-cli.js44
2 files changed, 45 insertions, 1 deletions
diff --git a/lib/ls.js b/lib/ls.js
index 8be186fdb..b5dc44888 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -434,7 +434,7 @@ function getExtras (data) {
function makeParseable (data, long, dir, depth, parent, d) {
depth = depth || 0
-
+ if (depth > npm.config.get('depth')) return [ makeParseable_(data, long, dir, depth, parent, d) ]
return [ makeParseable_(data, long, dir, depth, parent, d) ]
.concat(Object.keys(data.dependencies || {})
.sort(alphasort).map(function (d) {
diff --git a/test/tap/ls-depth-cli.js b/test/tap/ls-depth-cli.js
index 760681427..87eafced2 100644
--- a/test/tap/ls-depth-cli.js
+++ b/test/tap/ls-depth-cli.js
@@ -159,6 +159,50 @@ test('npm ls --depth=Infinity --json', function (t) {
)
})
+test('npm ls --depth=0 --parseable --long', function (t) {
+ common.npm(
+ ['ls', '--depth=0', '--parseable', '--long'],
+ EXEC_OPTS,
+ function (er, c, out) {
+ t.ifError(er, 'npm ls ran without issue')
+ t.equal(c, 0, 'ls ran without raising error code')
+ t.has(
+ out,
+ /.*test-package-with-one-dep@0\.0\.0/,
+ 'output contains test-package-with-one-dep'
+ )
+ t.doesNotHave(
+ out,
+ /.*test-package@0\.0\.0/,
+ 'output not contains test-package'
+ )
+ t.end()
+ }
+ )
+})
+
+test('npm ls --depth=1 --parseable --long', function (t) {
+ common.npm(
+ ['ls', '--depth=1', '--parseable', '--long'],
+ EXEC_OPTS,
+ function (er, c, out) {
+ t.ifError(er, 'npm ls ran without issue')
+ t.equal(c, 0, 'ls ran without raising error code')
+ t.has(
+ out,
+ /.*test-package-with-one-dep@0\.0\.0/,
+ 'output contains test-package-with-one-dep'
+ )
+ t.has(
+ out,
+ /.*test-package@0\.0\.0/,
+ 'output not contains test-package'
+ )
+ t.end()
+ }
+ )
+})
+
test('cleanup', function (t) {
cleanup()
t.end()