diff options
author | Zac <zdoege@gm.slc.edu> | 2016-03-04 04:31:22 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2016-03-11 01:38:12 +0300 |
commit | 611070f0f7a1e185c75cadae46179194084b398f (patch) | |
tree | bf6dc7293fe64c9d82d21759b8d67acf325f8820 | |
parent | ff9038227a1976b5e936442716d9877f43c6c9b4 (diff) |
ls: Made `npm ls --parseable` honor the `depth` option
Credit: @zacdoe
Reviewed-By: @iarna
PR-URL: https://github.com/npm/npm/pull/11773
Fixes: #11495
-rw-r--r-- | lib/ls.js | 2 | ||||
-rw-r--r-- | test/tap/ls-depth-cli.js | 44 |
2 files changed, 45 insertions, 1 deletions
@@ -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() |