From d33a34105f6ac5808524a1d438161f8bde78c60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Tue, 29 Mar 2022 12:05:54 +0100 Subject: [PATCH] cleanup(angular): fix ng-add e2e tests to correctly pass args based on the package manager (#9580) --- e2e/utils/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/utils/index.ts b/e2e/utils/index.ts index a84ce69bc3..9b82c4e2e9 100644 --- a/e2e/utils/index.ts +++ b/e2e/utils/index.ts @@ -429,7 +429,7 @@ export function runNgAdd( try { const pmc = getPackageManagerCommand(); packageInstall(packageName, null, version); - return execSync(`${pmc.run} ng g ${packageName}:ng-add ${command}`, { + return execSync(pmc.run(`ng g ${packageName}:ng-add`, command), { cwd: tmpProjPath(), env: { ...(opts.env || process.env), NX_INVOKED_BY_RUNNER: undefined }, encoding: 'utf-8', @@ -734,7 +734,7 @@ export function getPackageManagerCommand({ packageManager = detectPackageManager(path), } = {}): { createWorkspace: string; - run: string; + run: (script: string, args: string) => string; runNx: string; runNxSilent: string; runUninstalledPackage?: string | undefined; @@ -748,7 +748,7 @@ export function getPackageManagerCommand({ createWorkspace: `npx ${ +npmMajorVersion >= 7 ? '--yes' : '' } create-nx-workspace@${publishedVersion}`, - run: 'npm run', + run: (script: string, args: string) => `npm run ${script} -- ${args}`, runNx: `npx nx`, runNxSilent: `npx nx`, runUninstalledPackage: `npx`, @@ -758,7 +758,7 @@ export function getPackageManagerCommand({ yarn: { // `yarn create nx-workspace` is failing due to wrong global path createWorkspace: `yarn global add create-nx-workspace@${publishedVersion} && create-nx-workspace`, - run: 'yarn', + run: (script: string, args: string) => `yarn ${script} ${args}`, runNx: `yarn nx`, runNxSilent: `yarn --silent nx`, runUninstalledPackage: 'npx', @@ -768,7 +768,7 @@ export function getPackageManagerCommand({ // Pnpm 3.5+ adds nx to pnpm: { createWorkspace: `pnpx --yes create-nx-workspace@${publishedVersion}`, - run: 'pnpm run', + run: (script: string, args: string) => `pnpm run ${script} -- ${args}`, runNx: `pnpx nx`, runNxSilent: `pnpx nx`, runUninstalledPackage: 'pnpx --yes',