Skip to content

Commit

Permalink
fix: corrected the verification of Mono and Wine installation status (#…
Browse files Browse the repository at this point in the history
…488)

* fix: correct Mono and Wine existence checks

* refactor: Add Promise.all based on review feedback
  • Loading branch information
BitYoungjae authored Oct 24, 2023
1 parent 155c2c1 commit 2fb8e5c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { createTempDir } from './temp-utils';
import * as fs from 'fs-extra';
import { Metadata, SquirrelWindowsOptions, PersonMetadata } from './options';
import * as path from 'path';
import * as os from 'os';
import { exec } from 'child_process';
import spawn from './spawn-promise';
import template from 'lodash.template';

Expand All @@ -22,6 +24,15 @@ export function convertVersion(version: string): string {
}
}

function checkIfCommandExists(command: string): Promise<boolean> {
const checkCommand = os.platform() === 'win32' ? 'where' : 'which';
return new Promise((resolve) => {
exec(`${checkCommand} ${command}`, (error) => {
resolve(error ? false : true);
});
});
}


export async function createWindowsInstaller(options: SquirrelWindowsOptions): Promise<void> {
let useMono = false;
Expand All @@ -31,7 +42,12 @@ export async function createWindowsInstaller(options: SquirrelWindowsOptions): P

if (process.platform !== 'win32') {
useMono = true;
if (!wineExe || !monoExe) {
const [hasWine, hasMono] = await Promise.all([
checkIfCommandExists(wineExe),
checkIfCommandExists(monoExe)
]);

if (!hasWine || !hasMono) {
throw new Error('You must install both Mono and Wine on non-Windows');
}

Expand Down

0 comments on commit 2fb8e5c

Please sign in to comment.