@@ -3,6 +3,8 @@ import { createTempDir } from './temp-utils';
33import * as fs from 'fs-extra' ;
44import { Metadata , SquirrelWindowsOptions , PersonMetadata } from './options' ;
55import * as path from 'path' ;
6+ import * as os from 'os' ;
7+ import { exec } from 'child_process' ;
68import spawn from './spawn-promise' ;
79import template from 'lodash.template' ;
810
@@ -22,6 +24,15 @@ export function convertVersion(version: string): string {
2224 }
2325}
2426
27+ function checkIfCommandExists ( command : string ) : Promise < boolean > {
28+ const checkCommand = os . platform ( ) === 'win32' ? 'where' : 'which' ;
29+ return new Promise ( ( resolve ) => {
30+ exec ( `${ checkCommand } ${ command } ` , ( error ) => {
31+ resolve ( error ? false : true ) ;
32+ } ) ;
33+ } ) ;
34+ }
35+
2536
2637export async function createWindowsInstaller ( options : SquirrelWindowsOptions ) : Promise < void > {
2738 let useMono = false ;
@@ -31,7 +42,12 @@ export async function createWindowsInstaller(options: SquirrelWindowsOptions): P
3142
3243 if ( process . platform !== 'win32' ) {
3344 useMono = true ;
34- if ( ! wineExe || ! monoExe ) {
45+ const [ hasWine , hasMono ] = await Promise . all ( [
46+ checkIfCommandExists ( wineExe ) ,
47+ checkIfCommandExists ( monoExe )
48+ ] ) ;
49+
50+ if ( ! hasWine || ! hasMono ) {
3551 throw new Error ( 'You must install both Mono and Wine on non-Windows' ) ;
3652 }
3753
0 commit comments