Skip to content

Commit 6fe2bdc

Browse files
ruyadornoclaudiahdz
authored andcommitted
fix: npm ls --parseable --long output
PR-URL: #1547 Credit: @ruyadorno Close: #1547 Reviewed-by: @claudiahdz
1 parent 8788889 commit 6fe2bdc

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/ls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ function makeParseable_ (data, long, dir, depth, parent, d) {
545545

546546
return data.path +
547547
':' + (data._id || '') +
548-
':' + (data.realPath !== data.path ? data.realPath : '') +
548+
(data.link && data.link !== data.path ? ':' + data.link : '') +
549549
(data.extraneous ? ':EXTRANEOUS' : '') +
550550
(data.error && data.path !== path.resolve(npm.globalDir, '..') ? ':ERROR' : '') +
551551
(data.invalid ? ':INVALID' : '') +

test/tap/ls.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,40 @@ test('cleanup', function (t) {
169169
t.done()
170170
})
171171

172+
test('ls parseable long', function (t) {
173+
var fixture = new Tacks(
174+
Dir({
175+
'npm-test-ls': Dir({
176+
'package.json': File({
177+
name: 'npm-test-ls',
178+
version: '1.0.0',
179+
dependencies: {
180+
'dep': 'file:../dep'
181+
}
182+
})
183+
}),
184+
'dep': Dir({
185+
'package.json': File({
186+
name: 'dep',
187+
version: '1.0.0'
188+
})
189+
})
190+
})
191+
)
192+
withFixture(t, fixture, function (done) {
193+
common.npm([
194+
'ls', '--parseable', '--long'
195+
], {
196+
cwd: pkgpath
197+
}, function (err, code, stdout, stderr) {
198+
t.ifErr(err, 'ls succeeded')
199+
t.equal(0, code, 'exit 0 on ls')
200+
t.notMatch(stdout, /undefined/, 'must not output undefined for non-symlinked items')
201+
done()
202+
})
203+
})
204+
})
205+
172206
function withFixture (t, fixture, tester) {
173207
fixture.create(fixturepath)
174208
common.npm(['install'], {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy