Skip to content

Commit

Permalink
fix: npm ls --parseable --long output
Browse files Browse the repository at this point in the history
PR-URL: #1547
Credit: @ruyadorno
Close: #1547
Reviewed-by: @claudiahdz
  • Loading branch information
ruyadorno authored and claudiahdz committed Jul 21, 2020
1 parent 8788889 commit 6fe2bdc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function makeParseable_ (data, long, dir, depth, parent, d) {

return data.path +
':' + (data._id || '') +
':' + (data.realPath !== data.path ? data.realPath : '') +
(data.link && data.link !== data.path ? ':' + data.link : '') +
(data.extraneous ? ':EXTRANEOUS' : '') +
(data.error && data.path !== path.resolve(npm.globalDir, '..') ? ':ERROR' : '') +
(data.invalid ? ':INVALID' : '') +
Expand Down
34 changes: 34 additions & 0 deletions test/tap/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,40 @@ test('cleanup', function (t) {
t.done()
})

test('ls parseable long', function (t) {
var fixture = new Tacks(
Dir({
'npm-test-ls': Dir({
'package.json': File({
name: 'npm-test-ls',
version: '1.0.0',
dependencies: {
'dep': 'file:../dep'
}
})
}),
'dep': Dir({
'package.json': File({
name: 'dep',
version: '1.0.0'
})
})
})
)
withFixture(t, fixture, function (done) {
common.npm([
'ls', '--parseable', '--long'
], {
cwd: pkgpath
}, function (err, code, stdout, stderr) {
t.ifErr(err, 'ls succeeded')
t.equal(0, code, 'exit 0 on ls')
t.notMatch(stdout, /undefined/, 'must not output undefined for non-symlinked items')
done()
})
})
})

function withFixture (t, fixture, tester) {
fixture.create(fixturepath)
common.npm(['install'], {
Expand Down

0 comments on commit 6fe2bdc

Please sign in to comment.