From 045a3d71af29fc1773bdf57a368c875a76423873 Mon Sep 17 00:00:00 2001 From: Sergey Vohmyanin Date: Thu, 25 Aug 2022 23:19:28 +0300 Subject: [PATCH] fix(windows): node.js modules .bin commands does not appear available as executable, so invoke these commands as shell commands --- code/frameworks/angular/src/builders/utils/run-compodoc.ts | 1 + .../angular/src/client/docs/angular-properties.test.ts | 1 + code/lib/cli/src/add.ts | 1 + code/lib/cli/src/js-package-manager/JsPackageManager.ts | 1 + .../lib/cli/src/js-package-manager/JsPackageManagerFactory.ts | 4 ++-- code/lib/cli/src/link.ts | 1 + code/lib/cli/src/upgrade.ts | 3 ++- code/lib/codemod/src/index.js | 1 + .../web-components/src/docs/web-components-properties.test.ts | 1 + 9 files changed, 11 insertions(+), 3 deletions(-) diff --git a/code/frameworks/angular/src/builders/utils/run-compodoc.ts b/code/frameworks/angular/src/builders/utils/run-compodoc.ts index 74551841046b..dc6e541b58da 100644 --- a/code/frameworks/angular/src/builders/utils/run-compodoc.ts +++ b/code/frameworks/angular/src/builders/utils/run-compodoc.ts @@ -30,6 +30,7 @@ export const runCompodoc = ( context.logger.info(finalCompodocArgs.join(' ')); const child = spawn('npx', finalCompodocArgs, { cwd: context.workspaceRoot, + shell: true, }); child.stdout.on('data', (data) => { diff --git a/code/frameworks/angular/src/client/docs/angular-properties.test.ts b/code/frameworks/angular/src/client/docs/angular-properties.test.ts index 49c7f5661a66..24ce9e920001 100644 --- a/code/frameworks/angular/src/client/docs/angular-properties.test.ts +++ b/code/frameworks/angular/src/client/docs/angular-properties.test.ts @@ -21,6 +21,7 @@ const runCompodoc = (inputPath: string) => { // (and screwed around with relative paths as well, but couldn't get it working) spawnSync('yarn', ['compodoc', '-p', `${testDir}/tsconfig.json`, '-e', 'json', '-d', tmpDir], { stdio: 'inherit', + shell: true, }); const output = fs.readFileSync(`${tmpDir}/documentation.json`, 'utf8'); try { diff --git a/code/lib/cli/src/add.ts b/code/lib/cli/src/add.ts index f6fb63e3787b..f67c50f1e15a 100644 --- a/code/lib/cli/src/add.ts +++ b/code/lib/cli/src/add.ts @@ -123,6 +123,7 @@ const postinstallAddon = async (addonName: string, isOfficialAddon: boolean) => } spawnSync('npx', ['jscodeshift', '-t', codemod, configFile], { stdio: 'inherit', + shell: true, }); skipMsg = null; } catch (err) { diff --git a/code/lib/cli/src/js-package-manager/JsPackageManager.ts b/code/lib/cli/src/js-package-manager/JsPackageManager.ts index 46414f43b483..9998d0d93d64 100644 --- a/code/lib/cli/src/js-package-manager/JsPackageManager.ts +++ b/code/lib/cli/src/js-package-manager/JsPackageManager.ts @@ -386,6 +386,7 @@ export abstract class JsPackageManager { cwd: this.cwd, stdio: stdio ?? 'pipe', encoding: 'utf-8', + shell: true, }); if (commandResult.status !== 0) { diff --git a/code/lib/cli/src/js-package-manager/JsPackageManagerFactory.ts b/code/lib/cli/src/js-package-manager/JsPackageManagerFactory.ts index 371720418c8e..df1ad452ec1b 100644 --- a/code/lib/cli/src/js-package-manager/JsPackageManagerFactory.ts +++ b/code/lib/cli/src/js-package-manager/JsPackageManagerFactory.ts @@ -29,12 +29,12 @@ export class JsPackageManagerFactory { } function hasNPM(cwd?: string) { - const npmVersionCommand = spawnSync('npm', ['--version'], { cwd }); + const npmVersionCommand = spawnSync('npm', ['--version'], { cwd, shell: true }); return npmVersionCommand.status === 0; } function getYarnVersion(cwd?: string): 1 | 2 | undefined { - const yarnVersionCommand = spawnSync('yarn', ['--version'], { cwd }); + const yarnVersionCommand = spawnSync('yarn', ['--version'], { cwd, shell: true }); if (yarnVersionCommand.status !== 0) { return undefined; diff --git a/code/lib/cli/src/link.ts b/code/lib/cli/src/link.ts index ce3e419dcf98..f6da58c1d6c9 100644 --- a/code/lib/cli/src/link.ts +++ b/code/lib/cli/src/link.ts @@ -37,6 +37,7 @@ export const link = async ({ target, local, start }: LinkOptions) => { const version = spawnSync('yarn', ['--version'], { cwd: reproDir, stdio: 'pipe', + shell: true, }).stdout.toString(); if (!/^[23]\./.test(version)) { diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 2df15576bb94..90aeaa3c56b7 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -73,7 +73,7 @@ const warnPackages = (pkgs: Package[]) => pkgs.forEach((pkg) => logger.warn(`- ${formatPackage(pkg)}`)); export const checkVersionConsistency = () => { - const lines = spawnSync('npm', ['ls'], { stdio: 'pipe' }).output.toString().split('\n'); + const lines = spawnSync('npm', ['ls'], { stdio: 'pipe', shell: true }).output.toString().split('\n'); const storybookPackages = lines .map(getStorybookVersion) .filter(Boolean) @@ -165,6 +165,7 @@ export const upgrade = async ({ flags = addExtraFlags(EXTRA_FLAGS, flags, packageManager.retrievePackageJson()); const check = spawnSync('npx', ['npm-check-updates@latest', '/storybook/', ...flags], { stdio: 'pipe', + shell: true, }).output.toString(); logger.info(check); diff --git a/code/lib/codemod/src/index.js b/code/lib/codemod/src/index.js index daff5288b100..5d44b44210da 100644 --- a/code/lib/codemod/src/index.js +++ b/code/lib/codemod/src/index.js @@ -62,6 +62,7 @@ export async function runCodemod(codemod, { glob, logger, dryRun, rename, parser ['jscodeshift', '-t', `${TRANSFORM_DIR}/${codemod}.js`, ...parserArgs, ...files], { stdio: 'inherit', + shell: true, } ); } diff --git a/code/renderers/web-components/src/docs/web-components-properties.test.ts b/code/renderers/web-components/src/docs/web-components-properties.test.ts index 722f8bdb3291..6d43aa8e4848 100644 --- a/code/renderers/web-components/src/docs/web-components-properties.test.ts +++ b/code/renderers/web-components/src/docs/web-components-properties.test.ts @@ -13,6 +13,7 @@ const runWebComponentsAnalyzer = (inputPath: string) => { const customElementsFile = `${tmpDir}/custom-elements.json`; spawnSync('yarn', ['wca', 'analyze', inputPath, '--outFile', customElementsFile], { stdio: 'inherit', + shell: true, }); const output = fs.readFileSync(customElementsFile, 'utf8'); try {