Skip to content

Commit 23b44d8

Browse files
MSP-Greglarskanis
authored andcommitted
Use ridk enable to set MSYS2 ENV variables
Co-authored-by: Lars Kanis <[email protected]>
1 parent 6cc5359 commit 23b44d8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

windows.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export async function install(platform, engine, version) {
6666
}
6767
}
6868

69+
const ridk = `${rubyPrefix}\\bin\\ridk.cmd`
70+
if (fs.existsSync(ridk)) {
71+
await common.measure('Adding ridk env variables', async () => addRidkEnv(ridk))
72+
}
73+
6974
return rubyPrefix
7075
}
7176

@@ -191,3 +196,25 @@ export function addVCVARSEnv() {
191196
}
192197
return newPathEntries
193198
}
199+
200+
// Sets MSYS2 ENV variables set from running `ridk enable`
201+
//
202+
function addRidkEnv(ridk) {
203+
let newEnv = new Map()
204+
let cmd = `cmd.exe /c "${ridk} enable && set"`
205+
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
206+
newSet = newSet.filter(line => /^\S+=\S+/.test(line))
207+
newSet.forEach(s => {
208+
let [k,v] = common.partition(s, '=')
209+
newEnv.set(k,v)
210+
})
211+
212+
for (let [k, v] of newEnv) {
213+
if (process.env[k] !== v) {
214+
if (!/^Path$/i.test(k)) {
215+
console.log(`${k}=${v}`)
216+
core.exportVariable(k, v)
217+
}
218+
}
219+
}
220+
}

0 commit comments

Comments
 (0)