Skip to content

Commit

Permalink
Use --force when installing deps for git prepare scripts
Browse files Browse the repository at this point in the history
If a git dependency has conflicting peerDependencies, dependencies with
engines fields that don't match the current environment, and so on, it
isn't much help to crash the installation for these issues.  The user
installing the git dependency is likely not in a position to fix them,
but from npm and Arborist's points of view, it is the 'main' project
that has a problem (since the install is being run as a separate
process).

This commit passes '--force' to the npm child process that installs
dependencies for git packages before running their 'prepare' script, to
ignore all such issues (or reduce them to warnings).

Related to: npm/cli#2548

PR-URL: #63
Credit: @isaacs
Close: #63
Reviewed-by: @nlf
  • Loading branch information
isaacs committed Feb 1, 2021
1 parent bfeffda commit 0d0d76c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class FetcherBase {
this.npmBin = opts.npmBin || 'npm'

// command to install deps for preparing
this.npmInstallCmd = opts.npmInstallCmd || [ 'install' ]
this.npmInstallCmd = opts.npmInstallCmd || [ 'install', '--force' ]

// XXX fill more of this in based on what we know from this.opts
// we explicitly DO NOT fill in --tag, though, since we are often
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test-fetcher.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ Array [
exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd 1`] = `
Array [
"install",
"--force",
]
`

exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd with before 1`] = `
Array [
"install",
"--force",
]
`

Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ Array [
exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd 1`] = `
Array [
"install",
"--force",
]
`

exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd with before 1`] = `
Array [
"install",
"--force",
]
`

Expand Down

0 comments on commit 0d0d76c

Please sign in to comment.