diff --git a/lib/ci.js b/lib/ci.js index a0728f8a46467..a72e1c0cffba6 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -31,7 +31,7 @@ const ci = async () => { 'later to generate a package-lock.json file, then try again.' throw new Error(msg) }), - rimraf(`${where}/node_modules/`), + rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }), ]) // npm ci should never modify the lockfile or package.json await arb.reify({ save: false }) diff --git a/test/lib/ci.js b/test/lib/ci.js index 3c642ba930135..645fc6aed97e4 100644 --- a/test/lib/ci.js +++ b/test/lib/ci.js @@ -104,7 +104,8 @@ test('should remove existing node_modules before installing', (t) => { t.equal(options.save, false, 'npm ci should never save') // check if node_modules was removed before reifying const contents = await readdir(testDir) - t.equals(contents.indexOf('node_modules'), -1, 'node_modules does not exist') + const nodeModules = contents.filter((path) => path.startsWith('node_modules')) + t.same(nodeModules, ['node_modules'], 'should only have the node_modules directory') t.end() } }