ghaction-upx/src/main.ts

34 lines
927 B
TypeScript
Raw Permalink Normal View History

2020-01-17 01:36:42 -07:00
import * as os from 'os';
import * as context from './context';
2020-05-06 14:14:50 -06:00
import * as installer from './installer';
2020-01-08 14:26:34 -07:00
import * as core from '@actions/core';
import * as exec from '@actions/exec';
2020-05-07 04:11:19 -06:00
async function run(): Promise<void> {
2020-01-08 14:26:34 -07:00
try {
2020-01-17 01:36:42 -07:00
if (os.platform() == 'darwin') {
core.setFailed('Not supported on darwin platform');
return;
}
const inputs: context.Inputs = await context.getInputs();
const upx = await installer.getUPX(inputs.version);
2020-01-08 14:26:34 -07:00
const files: string[] = context.resolvePaths(inputs.files);
if (files.length == 0) {
core.warning(`No files were found. Please check the 'files' input.`);
2020-05-06 14:14:50 -06:00
return;
2020-01-08 14:26:34 -07:00
}
await context.asyncForEach(files, async filepath => {
core.startGroup(`Compressing ${filepath}...`);
await exec.exec(`${upx} ${inputs.args} ${filepath}`);
core.endGroup();
});
2020-01-08 14:26:34 -07:00
} catch (error) {
core.setFailed(error.message);
}
}
run();