Skip to content

Commit 8795e98

Browse files
authored
fix(windows): make compatible with latest node patch levels (#5802)
specify shell:true for .cmd/.bat launches
1 parent d3f2e70 commit 8795e98

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

lib/base-package-manager.ts

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export abstract class BasePackageManager implements INodePackageManager {
111111
await this.$childProcess.spawnFromEvent(npmExecutable, params, "close", {
112112
cwd: opts.cwd,
113113
stdio: stdioValue,
114+
shell: this.$hostInfo.isWindows,
114115
});
115116

116117
// Whenever calling "npm install" or "yarn add" without any arguments (hence installing all dependencies) no output is emitted on stdout

lib/commands/typings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class TypingsCommand implements ICommand {
173173
this.$hostInfo.isWindows ? "ns.cmd" : "ns",
174174
["prepare", "android"],
175175
"exit",
176-
{ stdio: "inherit" }
176+
{ stdio: "inherit", shell: this.$hostInfo.isWindows }
177177
);
178178
}
179179

lib/common/mobile/android/android-virtual-device-service.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
import { injector } from "../../yok";
2323

2424
export class AndroidVirtualDeviceService
25-
implements Mobile.IAndroidVirtualDeviceService {
25+
implements Mobile.IAndroidVirtualDeviceService
26+
{
2627
private androidHome: string;
2728
private mapEmulatorIdToImageIdentifier: IStringDictionary = {};
2829

@@ -211,7 +212,8 @@ export class AndroidVirtualDeviceService
211212
let result: ISpawnResult = null;
212213
let devices: Mobile.IDeviceInfo[] = [];
213214
let errors: string[] = [];
214-
const canExecuteAvdManagerCommand = await this.canExecuteAvdManagerCommand();
215+
const canExecuteAvdManagerCommand =
216+
await this.canExecuteAvdManagerCommand();
215217
if (!canExecuteAvdManagerCommand) {
216218
errors = [
217219
"Unable to execute avdmanager, ensure JAVA_HOME is set and points to correct directory",
@@ -221,7 +223,8 @@ export class AndroidVirtualDeviceService
221223
if (canExecuteAvdManagerCommand) {
222224
result = await this.$childProcess.trySpawnFromCloseEvent(
223225
this.pathToAvdManagerExecutable,
224-
["list", "avds"]
226+
["list", "avds"],
227+
{ shell: this.$hostInfo.isWindows }
225228
);
226229
} else if (
227230
this.pathToAndroidExecutable &&
@@ -403,9 +406,8 @@ export class AndroidVirtualDeviceService
403406
private getAvdManagerDeviceInfo(
404407
output: string
405408
): Mobile.IAvdManagerDeviceInfo {
406-
const avdManagerDeviceInfo: Mobile.IAvdManagerDeviceInfo = Object.create(
407-
null
408-
);
409+
const avdManagerDeviceInfo: Mobile.IAvdManagerDeviceInfo =
410+
Object.create(null);
409411

410412
// Split by `\n`, not EOL as the avdmanager and android executables print results with `\n` only even on Windows
411413
_.reduce(
@@ -437,9 +439,8 @@ export class AndroidVirtualDeviceService
437439
avdFilePath,
438440
AndroidVirtualDevice.CONFIG_INI_FILE_NAME
439441
);
440-
const configIniFileInfo = this.$androidIniFileParser.parseIniFile(
441-
configIniFilePath
442-
);
442+
const configIniFileInfo =
443+
this.$androidIniFileParser.parseIniFile(configIniFilePath);
443444

444445
const iniFilePath = this.getIniFilePath(configIniFileInfo, avdFilePath);
445446
const iniFileInfo = this.$androidIniFileParser.parseIniFile(iniFilePath);

lib/services/android-plugin-build-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
815815
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", {
816816
cwd: pluginBuildSettings.pluginDir,
817817
stdio: "inherit",
818+
shell: this.$hostInfo.isWindows,
818819
});
819820
} catch (err) {
820821
this.$errors.fail(

lib/services/android/gradle-command-service.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export class GradleCommandService implements IGradleCommandService {
2626
const { message, cwd, stdio, spawnOptions } = options;
2727
this.$logger.info(message);
2828

29-
const childProcessOptions = { cwd, stdio: stdio || "inherit" };
29+
const childProcessOptions = {
30+
cwd,
31+
stdio: stdio || "inherit",
32+
shell: this.$hostInfo.isWindows,
33+
};
3034
const gradleExecutable =
3135
options.gradlePath ??
3236
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
@@ -44,7 +48,7 @@ export class GradleCommandService implements IGradleCommandService {
4448
private async executeCommandSafe(
4549
gradleExecutable: string,
4650
gradleArgs: string[],
47-
childProcessOptions: { cwd: string; stdio: string },
51+
childProcessOptions: { cwd: string; stdio: string; shell: boolean },
4852
spawnOptions: ISpawnFromEventOptions
4953
): Promise<ISpawnResult> {
5054
try {

0 commit comments

Comments
 (0)