Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: delete the contents of node_modules only, not the directory #2083

Closed
wants to merge 1 commit into from
Closed
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
delete the contents of node_modules only
nlf committed Oct 29, 2020
commit f00d4756063dc491352ac513c4f42078beab7fcb
2 changes: 1 addition & 1 deletion lib/ci.js
Original file line number Diff line number Diff line change
@@ -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 } }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this include .bin and other dotfiles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! the default options passed to glob from rimraf are { nosort: true, silent: true } adding dot: true is the effective change here, which per glob's documentation:

You can make glob treat dots as normal characters by setting dot:true in the options.

])
// npm ci should never modify the lockfile or package.json
await arb.reify({ save: false })
3 changes: 2 additions & 1 deletion test/lib/ci.js
Original file line number Diff line number Diff line change
@@ -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()
}
}