Use ridk enable to set MSYS2 ENV variables

Co-authored-by: Lars Kanis <lars@greiz-reinsdorf.de>
This commit is contained in:
MSP-Greg
2022-01-13 19:25:34 +01:00
committed by Benoit Daloze
co-authored by Lars Kanis
parent 6cc535991c
commit 23b44d8ec5
+27
View File
@@ -66,6 +66,11 @@ export async function install(platform, engine, version) {
}
}
const ridk = `${rubyPrefix}\\bin\\ridk.cmd`
if (fs.existsSync(ridk)) {
await common.measure('Adding ridk env variables', async () => addRidkEnv(ridk))
}
return rubyPrefix
}
@@ -191,3 +196,25 @@ export function addVCVARSEnv() {
}
return newPathEntries
}
// Sets MSYS2 ENV variables set from running `ridk enable`
//
function addRidkEnv(ridk) {
let newEnv = new Map()
let cmd = `cmd.exe /c "${ridk} enable && set"`
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
newSet = newSet.filter(line => /^\S+=\S+/.test(line))
newSet.forEach(s => {
let [k,v] = common.partition(s, '=')
newEnv.set(k,v)
})
for (let [k, v] of newEnv) {
if (process.env[k] !== v) {
if (!/^Path$/i.test(k)) {
console.log(`${k}=${v}`)
core.exportVariable(k, v)
}
}
}
}