Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-02-02 00:40:44 +0300
committerDarcy Clarke <darcy@darcyclarke.me>2021-02-02 19:36:14 +0300
commit37613e4e686e4891210acaabc9c23f41456eda3f (patch)
treed898e0895b2d5f96a8d65f4b9387e5ddecd99ea6 /lib
parent22112a99ee92af2d6b5762b49aeb22858147af59 (diff)
fix(exec): use latest version when possible
pull latest packument when getting info about package to run, also install newer version if one is available and user has not specified a version (i.e. is defaulting to @latest) PR-URL: https://github.com/npm/cli/pull/2592 Credit: @wraithgar Closes: #2395 Closes: #2329 Reviewed-by: @darcyclarke
Diffstat (limited to 'lib')
-rw-r--r--lib/exec.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/exec.js b/lib/exec.js
index d36dd87cf..e90ec0866 100644
--- a/lib/exec.js
+++ b/lib/exec.js
@@ -169,8 +169,12 @@ const exec = async args => {
return await readPackageJson(pj)
} catch (er) {}
}
+ // Force preferOnline to true so we are making sure to pull in the latest
+ // This is especially useful if the user didn't give us a version, and
+ // they expect to be running @latest
return await pacote.manifest(p, {
...npm.flatOptions,
+ preferOnline: true,
})
}))
@@ -193,9 +197,13 @@ const exec = async args => {
const arb = new Arborist({ ...npm.flatOptions, path: installDir })
const tree = await arb.loadActual()
- // any that don't match the manifest we have, install them
- // add installDir/node_modules/.bin to pathArr
- const add = manis.filter(mani => manifestMissing(tree, mani))
+ // at this point, we have to ensure that we get the exact same
+ // version, because it's something that has only ever been installed
+ // by npm exec in the cache install directory
+ const add = manis.filter(mani => manifestMissing(tree, {
+ ...mani,
+ _from: `${mani.name}@${mani.version}`,
+ }))
.map(mani => mani._from)
.sort((a, b) => a.localeCompare(b))