This repository was archived by the owner on Jul 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,29 @@ import fs from 'fs';
44import path from 'path' ;
55
66const SHIM_DIR = path . resolve ( __dirname , 'shims' ) ;
7+ const SHIM_EXTENSION = isWindows ( ) ? 'cmd' : 'sh' ;
8+
79if ( ! fs . existsSync ( SHIM_DIR ) ) {
810 fs . mkdirSync ( SHIM_DIR ) ;
911}
1012
13+ function isWindows ( ) : boolean {
14+ return process . platform === 'win32' ;
15+ }
16+
17+ function getTemplate ( shell : string ) : string {
18+ let template ;
19+ if ( isWindows ( ) ) {
20+ template = 'SET' ;
21+ } else {
22+ template = `#!${ shell } -i\nexport` ;
23+ }
24+
25+ return template ;
26+ }
27+
1128function mkShim ( shell : string , shimPath : string ) : boolean {
12- const template = `#! ${ shell } -i\nexport` ;
29+ const template = getTemplate ( shell ) ;
1330 let result = false ;
1431
1532 try {
@@ -25,7 +42,7 @@ function mkShim(shell: string, shimPath: string): boolean {
2542
2643function getShim ( ) : string {
2744 const shellName : string = path . basename ( defaultShell ) ;
28- const shimPath = path . join ( SHIM_DIR , `env.${ shellName } ` ) ;
45+ const shimPath = path . join ( SHIM_DIR , `env.${ shellName } . ${ SHIM_EXTENSION } ` ) ;
2946 if ( ! fs . existsSync ( shimPath ) ) {
3047 mkShim ( defaultShell , shimPath ) ;
3148 }
@@ -64,6 +81,8 @@ function processExportLine(line: string): string[] {
6481
6582const RUBY_ENVIRONMENT_VARIABLES = [
6683 'PATH' ,
84+ 'Path' , // Windows
85+ 'PATHEXT' , // Windows
6786 'RUBY_VERSION' ,
6887 'RUBY_ROOT' ,
6988 'GEM_HOME' ,
You can’t perform that action at this time.
0 commit comments