@@ -3,17 +3,20 @@ import * as fs from 'fs';
3
3
import * as util from 'util' ;
4
4
import { spawn , ChildProcess , SpawnOptions } from 'child_process' ;
5
5
import * as GSettings from 'node-gsettings-wrapper' ;
6
- import * as commandExists from 'command-exists' ;
6
+ import * as ensureCommandExists from 'command-exists' ;
7
7
8
8
import findOsxExecutableCb = require( 'osx-find-executable' ) ;
9
9
const findOsxExecutable = util . promisify ( findOsxExecutableCb ) ;
10
10
11
11
import { Interceptor } from '.' ;
12
12
import { HtkConfig } from '../config' ;
13
+ import { reportError } from '../error-tracking' ;
13
14
14
15
const checkAccess = util . promisify ( fs . access ) ;
15
16
const canAccess = ( path : string ) => checkAccess ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
16
17
18
+ const commandExists = ( path : string ) => ensureCommandExists ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
19
+
17
20
const DEFAULT_GIT_BASH_PATH = 'C:/Program Files/git/git-bash.exe' ;
18
21
19
22
interface SpawnArgs {
@@ -24,7 +27,7 @@ interface SpawnArgs {
24
27
25
28
const getTerminalCommand = _ . memoize ( async ( ) : Promise < SpawnArgs | null > => {
26
29
if ( process . platform === 'win32' ) {
27
- if ( await commandExists ( 'git-bash' ) . catch ( ( ) => false ) ) {
30
+ if ( await commandExists ( 'git-bash' ) ) {
28
31
return { command : 'git-bash' } ;
29
32
} else if ( await canAccess ( DEFAULT_GIT_BASH_PATH ) ) {
30
33
return { command : DEFAULT_GIT_BASH_PATH } ;
@@ -38,10 +41,12 @@ const getTerminalCommand = _.memoize(async (): Promise<SpawnArgs | null> => {
38
41
) ;
39
42
40
43
const defaultTerminal = gSettingsTerminalKey && gSettingsTerminalKey . getValue ( ) ;
41
- if ( defaultTerminal ) return { command : defaultTerminal } ;
44
+ if ( defaultTerminal && commandExists ( defaultTerminal ) ) {
45
+ return { command : defaultTerminal } ;
46
+ }
42
47
}
43
48
44
- if ( await commandExists ( 'xterm' ) . catch ( ( ) => false ) ) {
49
+ if ( await commandExists ( 'xterm' ) ) {
45
50
return { command : 'xterm' } ;
46
51
}
47
52
} else if ( process . platform === 'darwin' ) {
0 commit comments