Skip to content

Commit

Permalink
Fix spawn calls for node LTS versions (#13614)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Apr 25, 2024
1 parent cf7dc82 commit de86a44
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
10 changes: 8 additions & 2 deletions dev-packages/application-manager/src/application-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class ApplicationProcess {
) { }

spawn(command: string, args?: string[], options?: cp.SpawnOptions): cp.ChildProcess {
return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, options));
return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, {
...options,
shell: true
}));
}

fork(modulePath: string, args?: string[], options?: cp.ForkOptions): cp.ChildProcess {
Expand All @@ -50,7 +53,10 @@ export class ApplicationProcess {

spawnBin(command: string, args: string[], options?: cp.SpawnOptions): cp.ChildProcess {
const binPath = this.resolveBin(command);
return this.spawn(binPath, args, options);
return this.spawn(binPath, args, {
...options,
shell: true
});
}

protected resolveBin(command: string): string {
Expand Down
7 changes: 3 additions & 4 deletions dev-packages/cli/bin/theia-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const path = require('path');
const cp = require('child_process');

const patchPackage= require.resolve('patch-package');
const patchPackage = require.resolve('patch-package');
console.log(`patch-package = ${patchPackage}`);

const patchesDir = path.join('.', 'node_modules', '@theia', 'cli', 'patches');
Expand All @@ -28,10 +28,9 @@ console.log(`patchesdir = ${patchesDir}`);

const env = Object.assign({}, process.env);

const scriptProcess = cp.exec(`node ${patchPackage} --patch-dir "${patchesDir}"`, {
const scriptProcess = cp.exec(`node "${patchPackage}" --patch-dir "${patchesDir}"`, {
cwd: process.cwd(),
env,

env
});

scriptProcess.stdout.pipe(process.stdout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ export class NativeWebpackPlugin {
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
await this.copyExecutable(dllFile, targetDllFile);
} else {
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
const targetFile = path.join(targetDirectory, 'spawn-helper');
await this.copyExecutable(sourceFile, targetFile);
}
}

Expand Down
3 changes: 2 additions & 1 deletion dev-packages/private-re-exports/src/package-re-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export class PackageReExports {
ELECTRON_RUN_AS_NODE: '1'
},
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'inherit']
stdio: ['ignore', 'pipe', 'inherit'],
shell: true
});
const [packageRoot, reExports] = JSON.parse(stdout) as [string, ReExport[]];
return new PackageReExports(packageName, packageRoot, reExports);
Expand Down
2 changes: 1 addition & 1 deletion packages/process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Theia process support.",
"dependencies": {
"@theia/core": "1.48.0",
"node-pty": "0.11.0-beta17",
"node-pty": "0.11.0-beta24",
"string-argv": "^0.1.1",
"tslib": "^2.6.2"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/process/src/node/pseudo-pty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ export class PseudoPty implements IPty {
pause(): void { }

resume(): void { }

clear(): void { }
}
4 changes: 3 additions & 1 deletion packages/terminal/src/node/shell-terminal-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class ShellTerminalServer extends BaseTerminalServer implements IShellTer
private spawnAsPromised(command: string, args: string[]): Promise<string> {
return new Promise((resolve, reject) => {
let stdout = '';
const child = cp.spawn(command, args);
const child = cp.spawn(command, args, {
shell: true
});
if (child.pid) {
child.stdout.on('data', (data: Buffer) => {
stdout += data.toString();
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8594,12 +8594,12 @@ node-preload@^0.2.1:
dependencies:
process-on-spawn "^1.0.0"

[email protected]beta17:
version "0.11.0-beta17"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.11.0-beta17.tgz#7df6a60dced6bf7a3a282b65cf51980c68954af6"
integrity sha512-JALo4LgYKmzmmXI23CIfS6DpCuno647YJpNg3RT6jCKTHWrt+RHeB6JAlb/pJG9dFNSeaiIAWD+0waEg2AzlfA==
[email protected]beta24:
version "0.11.0-beta24"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.11.0-beta24.tgz#084841017187656edaf14b459946c4a1d7cf8392"
integrity sha512-CzItw3hitX+wnpw9dHA/A+kcbV7ETNKrsyQJ+s0ZGzsu70+CSGuIGPLPfMnAc17vOrQktxjyRQfaqij75GVJFw==
dependencies:
nan "^2.14.0"
nan "^2.17.0"

node-releases@^2.0.14:
version "2.0.14"
Expand Down

0 comments on commit de86a44

Please sign in to comment.