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

CLI: Fix spawning child processes on windows #19019

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/frameworks/angular/src/builders/utils/run-compodoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export abstract class JsPackageManager {
cwd: this.cwd,
stdio: stdio ?? 'pipe',
encoding: 'utf-8',
shell: true,
});

if (commandResult.status !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion code/lib/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions code/lib/codemod/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down