Skip to content

Commit 2a680e9

Browse files
nlfruyadorno
authored andcommitted
delete the contents of node_modules only
PR-URL: #2083 Credit: @nlf Close: #2083 Reviewed-by: @darcyclarke
1 parent 81d6cee commit 2a680e9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/ci.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ci = async () => {
3131
'later to generate a package-lock.json file, then try again.'
3232
throw new Error(msg)
3333
}),
34-
rimraf(`${where}/node_modules/`),
34+
rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }),
3535
])
3636
// npm ci should never modify the lockfile or package.json
3737
await arb.reify({ save: false })

test/lib/ci.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ test('should remove existing node_modules before installing', (t) => {
104104
t.equal(options.save, false, 'npm ci should never save')
105105
// check if node_modules was removed before reifying
106106
const contents = await readdir(testDir)
107-
t.equals(contents.indexOf('node_modules'), -1, 'node_modules does not exist')
107+
const nodeModules = contents.filter((path) => path.startsWith('node_modules'))
108+
t.same(nodeModules, ['node_modules'], 'should only have the node_modules directory')
108109
t.end()
109110
}
110111
}

0 commit comments

Comments
 (0)