@@ -36,14 +36,16 @@ export async function install(platform, ruby) {
3636 // we use certs and embedded MSYS2 from hostedRuby
3737 const hostedRuby = latestHostedRuby ( )
3838
39- let toolsPath = ( version === 'mswin' ) ?
39+ let toolsPaths = ( version === 'mswin' ) ?
4040 await setupMSWin ( hostedRuby ) : await setupMingw ( hostedRuby , version )
41+ const newPathEntries = [ `${ rubyPrefix } \\bin` , ...toolsPaths ]
4142
43+ // Install Bundler if needed
4244 if ( ! fs . existsSync ( `${ rubyPrefix } \\bin\\bundle.cmd` ) ) {
4345 await exec . exec ( `${ rubyPrefix } \\bin\\gem install bundler -v "~> 1" --no-document` )
4446 }
4547
46- return [ rubyPrefix , toolsPath ]
48+ return [ rubyPrefix , newPathEntries ]
4749}
4850
4951function latestHostedRuby ( ) {
@@ -67,7 +69,8 @@ async function setupMingw(hostedRuby, version) {
6769 const hostedMSYS2 = `${ hostedRuby } \\msys64`
6870 await exec . exec ( `cmd /c mklink /D ${ msys2 } ${ hostedMSYS2 } ` )
6971 }
70- return `${ msys2 } \\mingw64\\bin;${ msys2 } \\usr\\bin`
72+
73+ return [ `${ msys2 } \\mingw64\\bin` , `${ msys2 } \\usr\\bin` ]
7174}
7275
7376async function setupMSWin ( hostedRuby ) {
@@ -83,41 +86,36 @@ async function setupMSWin(hostedRuby) {
8386 const hostedCert = `${ hostedRuby } \\ssl\\cert.pem`
8487 fs . copyFileSync ( hostedCert , cert )
8588 }
89+
8690 return addVCVARSEnv ( )
8791}
8892
8993/* Sets msvc environment for use in Actions
9094 * allows steps to run without running vcvars*.bat, also allows using PS scripts
9195 * adds a convenience VCVARS environment variable
92- * this assumes a single Visual Studio version being available in the windows-latest image
93- */
96+ * this assumes a single Visual Studio version being available in the windows-latest image */
9497export function addVCVARSEnv ( ) {
9598 const vcVars = '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"'
9699 core . exportVariable ( 'VCVARS' , vcVars )
97100
98101 let newEnv = new Map ( )
99-
100102 let cmd = `cmd.exe /c "${ vcVars } && set"`
101-
102103 let newSet = cp . execSync ( cmd ) . toString ( ) . trim ( ) . split ( / \r ? \n / )
103-
104104 newSet = newSet . filter ( line => line . match ( / \S = \S / ) )
105-
106105 newSet . forEach ( s => {
107106 let [ k , v ] = s . split ( '=' , 2 )
108107 newEnv . set ( k , v )
109108 } )
110109
111- let pathAdd
112-
113- newEnv . forEach ( ( v , k , ) => {
110+ let newPathEntries = null
111+ for ( let [ k , v ] of newEnv ) {
114112 if ( process . env [ k ] !== v ) {
115113 if ( k === 'Path' ) {
116- pathAdd = v . replace ( process . env [ 'Path' ] , '' )
114+ newPathEntries = v . replace ( process . env [ 'Path' ] , '' )
117115 } else {
118116 core . exportVariable ( k , v )
119117 }
120118 }
121- } )
122- return pathAdd
119+ }
120+ return [ newPathEntries ]
123121}
0 commit comments