Skip to content

Commit 7ddbf2c

Browse files
committed
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)
1 parent 7b1a539 commit 7ddbf2c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/exec.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,12 @@ const exec = async args => {
169169
return await readPackageJson(pj)
170170
} catch (er) {}
171171
}
172+
// Force preferOnline to true so we are making sure to pull in the latest
173+
// This is especially useful if the user didn't give us a version, and
174+
// they expect to be running @latest
172175
return await pacote.manifest(p, {
173176
...npm.flatOptions,
177+
preferOnline: true,
174178
})
175179
}))
176180

@@ -193,9 +197,13 @@ const exec = async args => {
193197
const arb = new Arborist({ ...npm.flatOptions, path: installDir })
194198
const tree = await arb.loadActual()
195199

196-
// any that don't match the manifest we have, install them
197-
// add installDir/node_modules/.bin to pathArr
198-
const add = manis.filter(mani => manifestMissing(tree, mani))
200+
// at this point, we have to ensure that we get the exact same
201+
// version, because it's something that has only ever been installed
202+
// by npm exec in the cache install directory
203+
const add = manis.filter(mani => manifestMissing(tree, {
204+
...mani,
205+
_from: `${mani.name}@${mani.version}`,
206+
}))
199207
.map(mani => mani._from)
200208
.sort((a, b) => a.localeCompare(b))
201209

0 commit comments

Comments
 (0)