1
1
import * as _ from 'lodash' ;
2
2
import * as fs from 'fs' ;
3
+ import * as path from 'path' ;
3
4
import * as util from 'util' ;
4
5
import { spawn , ChildProcess , SpawnOptions } from 'child_process' ;
5
6
import * as GSettings from 'node-gsettings-wrapper' ;
@@ -18,6 +19,7 @@ const canAccess = (path: string) => checkAccess(path).then(() => true).catch(()
18
19
const commandExists = ( path : string ) : Promise < boolean > => ensureCommandExists ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
19
20
20
21
const DEFAULT_GIT_BASH_PATH = 'C:/Program Files/git/git-bash.exe' ;
22
+ const PATH_VAR_SEPARATOR = process . platform === 'win32' ? ';' : ':' ;
21
23
22
24
interface SpawnArgs {
23
25
command : string ;
@@ -94,7 +96,7 @@ export class TerminalInterceptor implements Interceptor {
94
96
const { command, args, options } = terminalSpawnArgs ;
95
97
96
98
const childProc = spawn ( command , args || [ ] , _ . assign ( options || { } , {
97
- env : _ . assign ( {
99
+ env : _ . assign ( { } , process . env , {
98
100
'http_proxy' : `http://localhost:${ proxyPort } ` ,
99
101
'HTTP_PROXY' : `http://localhost:${ proxyPort } ` ,
100
102
'https_proxy' : `http://localhost:${ proxyPort } ` ,
@@ -109,8 +111,11 @@ export class TerminalInterceptor implements Interceptor {
109
111
// Trust cert when using Perl LWP
110
112
'PERL_LWP_SSL_CA_FILE' : this . config . https . certPath ,
111
113
// Trust cert for HTTPS requests from Git
112
- 'GIT_SSL_CAINFO' : this . config . https . certPath
113
- } , process . env ) ,
114
+ 'GIT_SSL_CAINFO' : this . config . https . certPath ,
115
+
116
+ // Prepend our bin overrides into $PATH
117
+ 'PATH' : `${ path . join ( __dirname , 'terminal-wrappers' ) } ${ PATH_VAR_SEPARATOR } ${ process . env . PATH } `
118
+ } ) ,
114
119
cwd : process . env . HOME || process . env . USERPROFILE
115
120
} ) ) ;
116
121
0 commit comments