Skip to content
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

Merged
merged 1 commit into from
May 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/nx/src/utils/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dirSync } from 'tmp';
import { promisify } from 'util';
import { readJsonFile, writeJsonFile } from './fileutils';
import { PackageJson } from './package-json';
import { gte } from 'semver';
import { gte, lt } from 'semver';

const execAsync = promisify(exec);

Expand Down Expand Up @@ -63,10 +63,8 @@ export function getPackageManagerCommand(
}),
pnpm: () => {
const pnpmVersion = getPackageManagerVersion('pnpm');
let useExec = false;
if (gte(pnpmVersion, '6.13.0')) {
useExec = true;
}
const useExec = gte(pnpmVersion, '6.13.0');
const includeDoubleDashBeforeArgs = lt(pnpmVersion, '7.0.0');
return {
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
ciInstall: 'pnpm install --frozen-lockfile',
Expand All @@ -75,7 +73,10 @@ export function getPackageManagerCommand(
addGlobal: 'pnpm add -g',
rm: 'pnpm rm',
exec: useExec ? 'pnpm exec' : 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
run: (script: string, args: string) =>
includeDoubleDashBeforeArgs
? `pnpm run ${script} -- ${args}`
: `pnpm run ${script} ${args}`,

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',
             };
         },

list: 'pnpm ls --depth 100',
};
},
Expand Down