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
fix(core): call pnpm run
without --
for pnpm v7
#10305
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -67,6 +67,7 @@ export function getPackageManagerCommand( | |||
if (gte(pnpmVersion, '6.13.0')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you perhaps fix useExec
to const useExec = gte(pnpmVersion, '6.13.0');
?
You did it the right way and seeing the useExec
above kinda hurts the eyes 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, agreed. Updated.
Starting in pnpm v7 all command line arguments after the script name are passed to a script's arguments when using `pnpm run <script>`, including `--`. This can cause problems when there are no command line arguments, because it will pass `--` without anything following, which some scripts can't handle. In order to preserve the old functionality, we check if the pnpm version is less than 7.0.0. If it is, we include `--` before the args, otherwise we don't. Closes nrwl#10111
52ce818
to
707a3b4
Compare
run: (script: string, args: string) => | ||
includeDoubleDashBeforeArgs | ||
? `pnpm run ${script} -- ${args}` | ||
: `pnpm run ${script} ${args}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case anyone is looking to patch v13, I created this patch for @nrwl/tao@13.8.0
:
diff --git a/src/shared/package-manager.js b/src/shared/package-manager.js
index b74ffe01bc7cb161ac46462d723d8f521ec5a849..2ced85a576ad95bc2d18b363529d721d471408b2 100644
--- a/src/shared/package-manager.js
+++ b/src/shared/package-manager.js
@@ -39,17 +39,25 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
}),
pnpm: () => {
const [major, minor] = getPackageManagerVersion('pnpm').split('.');
+ const majorVersion = +major
+
let useExec = false;
- if (+major >= 6 && +minor >= 13) {
+ if (majorVersion >= 6 && +minor >= 13) {
useExec = true;
}
+
+ const includeDoubleDashBeforeArgs = majorVersion < 7;
+
return {
install: 'pnpm install --no-frozen-lockfile',
add: 'pnpm add',
addDev: 'pnpm add -D',
rm: 'pnpm rm',
exec: useExec ? 'pnpm exec' : 'pnpx',
- run: (script, args) => `pnpm run ${script} -- ${args}`,
+ run: (script, args) =>
+ includeDoubleDashBeforeArgs
+ ? `pnpm run ${script} -- ${args}`
+ : `pnpm run ${script} ${args}`,
list: 'pnpm ls --depth 100',
};
},
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Starting in pnpm v7 all command line arguments after the script name are passed to a script's arguments when using
pnpm run <script>
, including--
. This can cause problems when there are no command line arguments, because it will pass--
without anything following, which some scripts can't handle. In order to preserve the old functionality, we check if the pnpm version is less than 7.0.0. If it is, we include--
before the args, otherwise we don't.Closes #10111
Current Behavior
Appending
--
topnpm run <script>
when there are no arguments.Expected Behavior
Only include
--
for pnpm <7.0.0.Related Issue(s)
Fixes #10111