Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const { resolve } = require('path')
const t = require('tap')
const requireInject = require('require-inject')

const { utimesSync } = require('fs')
const touchHiddenPackageLock = prefix => {
const later = new Date(Date.now() + 10000)
utimesSync(`${prefix}/node_modules/.package-lock.json`, later, later)
}

t.cleanSnapshot = str => str.split(/\r\n/).join('\n')

const simpleNmFixture = {
Expand Down Expand Up @@ -1186,6 +1192,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing aliases')
t.end()
Expand Down Expand Up @@ -1231,6 +1238,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], (err) => {
t.ifError(err, 'npm ls')
t.matchSnapshot(redactCwd(result), 'should output tree containing git refs')
Expand Down Expand Up @@ -1329,6 +1337,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should not be printed in tree output')
t.end()
Expand Down Expand Up @@ -2228,6 +2237,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing aliases')
t.end()
Expand Down Expand Up @@ -2272,6 +2282,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing git refs')
t.end()
Expand Down Expand Up @@ -2325,6 +2336,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should not be printed in tree output')
t.end()
Expand Down Expand Up @@ -3688,6 +3700,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down Expand Up @@ -3747,6 +3760,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down Expand Up @@ -3830,6 +3844,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down