fix(core): use pnpm exec instead of pnpx (#7695)

pnpm is deprecating pnpx and suggests using pnpm exec instead.
pnpx still works at the moment, but if for whatever reason it
isn't installed then this pr can make create-nx-worksapce stsill work.

[pnpx documenation](https://pnpm.io/pnpx-cli)
This commit is contained in:
Jay McDoniel 2021-11-12 08:49:53 -08:00 committed by GitHub
parent 86baac49f5
commit 474dc283ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View File

@ -53,12 +53,17 @@ export function getPackageManagerCommand(
};
case 'pnpm':
const [major, minor] = getPackageManagerVersion('pnpm').split('.');
let useExec = false;
if (+major >= 6 && +minor >= 13) {
useExec = true;
}
return {
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
add: 'pnpm add',
addDev: 'pnpm add -D',
rm: 'pnpm rm',
exec: 'pnpx',
exec: useExec ? 'pnpm exec' : 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
list: 'pnpm ls --depth 100',
};

View File

@ -49,15 +49,22 @@ export function getPackageManagerCommand(
run: (script: string, args: string) => `yarn ${script} ${args}`,
list: 'yarn list',
}),
pnpm: () => ({
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
add: 'pnpm add',
addDev: 'pnpm add -D',
rm: 'pnpm rm',
exec: 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
list: 'pnpm ls --depth 100',
}),
pnpm: () => {
const [major, minor] = getPackageManagerVersion('pnpm').split('.');
let useExec = false;
if (+major >= 6 && +minor >= 13) {
useExec = true;
}
return {
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
add: 'pnpm add',
addDev: 'pnpm add -D',
rm: 'pnpm rm',
exec: useExec ? 'pnpm exec' : 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
list: 'pnpm ls --depth 100',
};
},
npm: () => {
process.env.npm_config_legacy_peer_deps ??= 'true';