@@ -3,17 +3,20 @@ import * as fs from 'fs';
33import * as util from 'util' ;
44import { spawn , ChildProcess , SpawnOptions } from 'child_process' ;
55import * as GSettings from 'node-gsettings-wrapper' ;
6- import * as commandExists from 'command-exists' ;
6+ import * as ensureCommandExists from 'command-exists' ;
77
88import findOsxExecutableCb = require( 'osx-find-executable' ) ;
99const findOsxExecutable = util . promisify ( findOsxExecutableCb ) ;
1010
1111import { Interceptor } from '.' ;
1212import { HtkConfig } from '../config' ;
13+ import { reportError } from '../error-tracking' ;
1314
1415const checkAccess = util . promisify ( fs . access ) ;
1516const canAccess = ( path : string ) => checkAccess ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
1617
18+ const commandExists = ( path : string ) => ensureCommandExists ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
19+
1720const DEFAULT_GIT_BASH_PATH = 'C:/Program Files/git/git-bash.exe' ;
1821
1922interface SpawnArgs {
@@ -24,7 +27,7 @@ interface SpawnArgs {
2427
2528const getTerminalCommand = _ . memoize ( async ( ) : Promise < SpawnArgs | null > => {
2629 if ( process . platform === 'win32' ) {
27- if ( await commandExists ( 'git-bash' ) . catch ( ( ) => false ) ) {
30+ if ( await commandExists ( 'git-bash' ) ) {
2831 return { command : 'git-bash' } ;
2932 } else if ( await canAccess ( DEFAULT_GIT_BASH_PATH ) ) {
3033 return { command : DEFAULT_GIT_BASH_PATH } ;
@@ -38,10 +41,12 @@ const getTerminalCommand = _.memoize(async (): Promise<SpawnArgs | null> => {
3841 ) ;
3942
4043 const defaultTerminal = gSettingsTerminalKey && gSettingsTerminalKey . getValue ( ) ;
41- if ( defaultTerminal ) return { command : defaultTerminal } ;
44+ if ( defaultTerminal && commandExists ( defaultTerminal ) ) {
45+ return { command : defaultTerminal } ;
46+ }
4247 }
4348
44- if ( await commandExists ( 'xterm' ) . catch ( ( ) => false ) ) {
49+ if ( await commandExists ( 'xterm' ) ) {
4550 return { command : 'xterm' } ;
4651 }
4752 } else if ( process . platform === 'darwin' ) {
0 commit comments