11import * as _ from 'lodash' ;
22import * as fs from 'fs' ;
3+ import * as path from 'path' ;
34import * as util from 'util' ;
45import { spawn , ChildProcess , SpawnOptions } from 'child_process' ;
56import * as GSettings from 'node-gsettings-wrapper' ;
@@ -18,6 +19,7 @@ const canAccess = (path: string) => checkAccess(path).then(() => true).catch(()
1819const commandExists = ( path : string ) : Promise < boolean > => ensureCommandExists ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
1920
2021const DEFAULT_GIT_BASH_PATH = 'C:/Program Files/git/git-bash.exe' ;
22+ const PATH_VAR_SEPARATOR = process . platform === 'win32' ? ';' : ':' ;
2123
2224interface SpawnArgs {
2325 command : string ;
@@ -94,7 +96,7 @@ export class TerminalInterceptor implements Interceptor {
9496 const { command, args, options } = terminalSpawnArgs ;
9597
9698 const childProc = spawn ( command , args || [ ] , _ . assign ( options || { } , {
97- env : _ . assign ( {
99+ env : _ . assign ( { } , process . env , {
98100 'http_proxy' : `http://localhost:${ proxyPort } ` ,
99101 'HTTP_PROXY' : `http://localhost:${ proxyPort } ` ,
100102 'https_proxy' : `http://localhost:${ proxyPort } ` ,
@@ -109,8 +111,11 @@ export class TerminalInterceptor implements Interceptor {
109111 // Trust cert when using Perl LWP
110112 'PERL_LWP_SSL_CA_FILE' : this . config . https . certPath ,
111113 // 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+ } ) ,
114119 cwd : process . env . HOME || process . env . USERPROFILE
115120 } ) ) ;
116121
0 commit comments