@@ -10,27 +10,23 @@ import * as ensureCommandExists from 'command-exists';
1010import findOsxExecutableCb = require( 'osx-find-executable' ) ;
1111const findOsxExecutable = util . promisify ( findOsxExecutableCb ) ;
1212
13- import { Interceptor } from '.' ;
14- import { HtkConfig } from '../config' ;
15- import { reportError } from '../error-tracking' ;
13+ import { Interceptor } from '..' ;
14+ import { HtkConfig } from '../../config' ;
15+ import { reportError } from '../../error-tracking' ;
16+ import { OVERRIDE_BIN_PATH , getTerminalEnvVars } from './terminal-env-overrides' ;
1617
1718const checkAccess = util . promisify ( fs . access ) ;
1819const canAccess = ( path : string ) => checkAccess ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
1920
2021const commandExists = ( path : string ) : Promise < boolean > => ensureCommandExists ( path ) . then ( ( ) => true ) . catch ( ( ) => false ) ;
2122
2223const DEFAULT_GIT_BASH_PATH = 'C:/Program Files/git/git-bash.exe' ;
23- const PATH_VAR_SEPARATOR = process . platform === 'win32' ? ';' : ':' ;
2424const SHELL = ( process . env . SHELL || '' ) . split ( '/' ) . slice ( - 1 ) [ 0 ] ;
2525
26- const OVERRIDES_DIR = path . join ( __dirname , '..' , '..' , 'overrides' ) ;
27-
28- const OVERRIDE_BIN_PATH = path . join ( OVERRIDES_DIR , 'path' ) ;
2926// Generate POSIX paths for git-bash on Windows (or use the normal path everywhere where)
3027const POSIX_OVERRIDE_BIN_PATH = process . platform === 'win32'
3128 ? OVERRIDE_BIN_PATH . replace ( / \\ / g, '/' ) . replace ( / ^ ( \w + ) : / , ( _all , driveLetter ) => `/${ driveLetter . toLowerCase ( ) } ` )
3229 : OVERRIDE_BIN_PATH ;
33- const OVERRIDE_RUBYGEMS_PATH = path . join ( OVERRIDES_DIR , 'gems' ) ;
3430
3531interface SpawnArgs {
3632 command : string ;
@@ -365,41 +361,7 @@ export class TerminalInterceptor implements Interceptor {
365361 command ,
366362 ( args || [ ] ) ,
367363 _ . assign ( options || { } , {
368- env : _ . assign ( { } , process . env , {
369- 'http_proxy' : `http://localhost:${ proxyPort } ` ,
370- 'HTTP_PROXY' : `http://localhost:${ proxyPort } ` ,
371- 'https_proxy' : `http://localhost:${ proxyPort } ` ,
372- 'HTTPS_PROXY' : `http://localhost:${ proxyPort } ` ,
373- // Used by global-agent to configure node.js HTTP(S) defaults
374- 'GLOBAL_AGENT_HTTP_PROXY' : `http://localhost:${ proxyPort } ` ,
375- // Used by some CGI engines to avoid 'httpoxy' vulnerability
376- 'CGI_HTTP_PROXY' : `http://localhost:${ proxyPort } ` ,
377- // Used by npm, for versions that don't support HTTP_PROXY etc
378- 'npm_config_proxy' : `http://localhost:${ proxyPort } ` ,
379- 'npm_config_https_proxy' : `http://localhost:${ proxyPort } ` ,
380- // Stop npm warning about having a different 'node' in $PATH
381- 'npm_config_scripts_prepend_node_path' : 'false' ,
382-
383- // Trust cert when using OpenSSL with default settings
384- 'SSL_CERT_FILE' : this . config . https . certPath ,
385- // Trust cert when using Node 7.3.0+
386- 'NODE_EXTRA_CA_CERTS' : this . config . https . certPath ,
387- // Trust cert when using Requests (Python)
388- 'REQUESTS_CA_BUNDLE' : this . config . https . certPath ,
389- // Trust cert when using Perl LWP
390- 'PERL_LWP_SSL_CA_FILE' : this . config . https . certPath ,
391- // Trust cert for HTTPS requests from Git
392- 'GIT_SSL_CAINFO' : this . config . https . certPath ,
393-
394- 'HTTP_TOOLKIT_ACTIVE' : 'true' ,
395-
396- // Prepend our bin overrides into $PATH
397- 'PATH' : `${ OVERRIDE_BIN_PATH } ${ PATH_VAR_SEPARATOR } ${ process . env . PATH } ` ,
398- // Prepend our Ruby gem overrides into $LOAD_PATH
399- 'RUBYLIB' : process . env . RUBYLIB
400- ? `${ OVERRIDE_RUBYGEMS_PATH } :${ process . env . RUBYLIB } `
401- : OVERRIDE_RUBYGEMS_PATH
402- } ) ,
364+ env : _ . assign ( { } , process . env , getTerminalEnvVars ( proxyPort , this . config . https ) ) ,
403365 cwd : process . env . HOME || process . env . USERPROFILE
404366 } ) ) ;
405367
0 commit comments