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

fix(windows): make compatible with latest node patch levels #5802

Merged
merged 1 commit into from
May 13, 2024
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 lib/base-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export abstract class BasePackageManager implements INodePackageManager {
await this.$childProcess.spawnFromEvent(npmExecutable, params, "close", {
cwd: opts.cwd,
stdio: stdioValue,
shell: this.$hostInfo.isWindows,
});

// Whenever calling "npm install" or "yarn add" without any arguments (hence installing all dependencies) no output is emitted on stdout
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class TypingsCommand implements ICommand {
this.$hostInfo.isWindows ? "ns.cmd" : "ns",
["prepare", "android"],
"exit",
{ stdio: "inherit" }
{ stdio: "inherit", shell: this.$hostInfo.isWindows }
);
}

Expand Down
19 changes: 10 additions & 9 deletions lib/common/mobile/android/android-virtual-device-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
import { injector } from "../../yok";

export class AndroidVirtualDeviceService
implements Mobile.IAndroidVirtualDeviceService {
implements Mobile.IAndroidVirtualDeviceService
{
private androidHome: string;
private mapEmulatorIdToImageIdentifier: IStringDictionary = {};

Expand Down Expand Up @@ -211,7 +212,8 @@ export class AndroidVirtualDeviceService
let result: ISpawnResult = null;
let devices: Mobile.IDeviceInfo[] = [];
let errors: string[] = [];
const canExecuteAvdManagerCommand = await this.canExecuteAvdManagerCommand();
const canExecuteAvdManagerCommand =
await this.canExecuteAvdManagerCommand();
if (!canExecuteAvdManagerCommand) {
errors = [
"Unable to execute avdmanager, ensure JAVA_HOME is set and points to correct directory",
Expand All @@ -221,7 +223,8 @@ export class AndroidVirtualDeviceService
if (canExecuteAvdManagerCommand) {
result = await this.$childProcess.trySpawnFromCloseEvent(
this.pathToAvdManagerExecutable,
["list", "avds"]
["list", "avds"],
{ shell: this.$hostInfo.isWindows }
);
} else if (
this.pathToAndroidExecutable &&
Expand Down Expand Up @@ -403,9 +406,8 @@ export class AndroidVirtualDeviceService
private getAvdManagerDeviceInfo(
output: string
): Mobile.IAvdManagerDeviceInfo {
const avdManagerDeviceInfo: Mobile.IAvdManagerDeviceInfo = Object.create(
null
);
const avdManagerDeviceInfo: Mobile.IAvdManagerDeviceInfo =
Object.create(null);

// Split by `\n`, not EOL as the avdmanager and android executables print results with `\n` only even on Windows
_.reduce(
Expand Down Expand Up @@ -437,9 +439,8 @@ export class AndroidVirtualDeviceService
avdFilePath,
AndroidVirtualDevice.CONFIG_INI_FILE_NAME
);
const configIniFileInfo = this.$androidIniFileParser.parseIniFile(
configIniFilePath
);
const configIniFileInfo =
this.$androidIniFileParser.parseIniFile(configIniFilePath);

const iniFilePath = this.getIniFilePath(configIniFileInfo, avdFilePath);
const iniFileInfo = this.$androidIniFileParser.parseIniFile(iniFilePath);
Expand Down
1 change: 1 addition & 0 deletions lib/services/android-plugin-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", {
cwd: pluginBuildSettings.pluginDir,
stdio: "inherit",
shell: this.$hostInfo.isWindows,
});
} catch (err) {
this.$errors.fail(
Expand Down
8 changes: 6 additions & 2 deletions lib/services/android/gradle-command-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export class GradleCommandService implements IGradleCommandService {
const { message, cwd, stdio, spawnOptions } = options;
this.$logger.info(message);

const childProcessOptions = { cwd, stdio: stdio || "inherit" };
const childProcessOptions = {
cwd,
stdio: stdio || "inherit",
shell: this.$hostInfo.isWindows,
};
const gradleExecutable =
options.gradlePath ??
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
Expand All @@ -44,7 +48,7 @@ export class GradleCommandService implements IGradleCommandService {
private async executeCommandSafe(
gradleExecutable: string,
gradleArgs: string[],
childProcessOptions: { cwd: string; stdio: string },
childProcessOptions: { cwd: string; stdio: string; shell: boolean },
spawnOptions: ISpawnFromEventOptions
): Promise<ISpawnResult> {
try {
Expand Down