Skip to content

fix: Corrected the verification of Mono and Wine installation status #488

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

Merged
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
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