Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
1138-4EB committed Oct 8, 2019
1 parent af57849 commit c9dfb87
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,44 @@ async function run() {
try {
if (process.platform !== 'win32') {
core.setFailed("MSYS2 does not work on non-windows platforms; please check the 'runs-on' field of the job");
return
return;
}

const tar = await io.which('tar', true);

const tmp_dir = process.env['RUNNER_TEMP']
const tmp_dir = process.env['RUNNER_TEMP'];
if (!tmp_dir) {
core.setFailed('environment variable RUNNER_TEMP is undefined');
return
return;
}
const dest = path.join(tmp_dir, 'msys')
const dest = path.join(tmp_dir, 'msys');

await io.mkdirP(dest)
await io.mkdirP(dest);

const distrib = await tc.downloadTool('http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.tar.xz')
const distrib = await tc.downloadTool('http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.tar.xz');

await exec.exec(`"${tar}"`, [
'-x', '-J', '--force-local',
// For some reason, GNU Tar on Windows expects paths to be slash-separated
'-C', dest.replace(/\\/g, '/'),
'-f', distrib
])
]);

let cmd = path.join(dest, 'msys2do.cmd')
fs.writeFileSync(cmd, ['setlocal', 'set MSYS2_PATH_TYPE=strict', `%~dp0\\msys64\\usr\\bin\\bash.exe -ilc "cd $OLDPWD && %*"`].join('\n\r'))
let cmd = path.join(dest, 'msys2do.cmd');
fs.writeFileSync(cmd, [
'setlocal',
'set MSYS2_PATH_TYPE=strict',
`%~dp0\\msys64\\usr\\bin\\bash.exe -ilc "cd $OLDPWD && %*"`
].join('\n\r'));

core.addPath(dest);

core.exportVariable('MSYSTEM', core.getInput('msystem'));

core.startGroup('Starting MSYS2 for the first time...')
core.startGroup('Starting MSYS2 for the first time...');
// For some reason, `msys2do` does not work
await exec.exec(`"${cmd}"`, ['uname', '-a'])
core.endGroup()
await exec.exec(`"${cmd}"`, ['uname', '-a']);
core.endGroup();
}
catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit c9dfb87

Please sign in to comment.