Skip to content
Merged
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
14 changes: 9 additions & 5 deletions packages/angular/cli/src/package-managers/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* enabling the injection of mock or test-specific implementations.
*/

import { spawn } from 'node:child_process';
import { type SpawnOptions, spawn } from 'node:child_process';
import { Stats } from 'node:fs';
import { mkdtemp, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { platform, tmpdir } from 'node:os';
import { join } from 'node:path';
import { PackageManagerError } from './error';

Expand Down Expand Up @@ -107,18 +107,22 @@ export const NodeJS_HOST: Host = {
} = {},
): Promise<{ stdout: string; stderr: string }> => {
const signal = options.timeout ? AbortSignal.timeout(options.timeout) : undefined;
const isWin32 = platform() === 'win32';

return new Promise((resolve, reject) => {
const childProcess = spawn(command, args, {
shell: false,
const spawnOptions = {
shell: isWin32,
stdio: options.stdio ?? 'pipe',
signal,
cwd: options.cwd,
env: {
...process.env,
...options.env,
},
});
} satisfies SpawnOptions;
const childProcess = isWin32
? spawn(`${command} ${args.join(' ')}`, spawnOptions)
: spawn(command, args, spawnOptions);

let stdout = '';
childProcess.stdout?.on('data', (data) => (stdout += data.toString()));
Expand Down