ghaction-upx/src/main.ts

33 lines
810 B
TypeScript
Raw Normal View History

2020-01-08 14:26:34 -07:00
import * as fs from 'fs';
2020-01-17 01:36:42 -07:00
import * as os from 'os';
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;
}
2020-01-08 14:26:34 -07:00
const version = core.getInput('version') || 'latest';
const file = core.getInput('file', {required: true});
const args = core.getInput('args');
if (!fs.existsSync(file)) {
2020-05-06 14:14:50 -06:00
core.setFailed(`File to compress not found: ${file}`);
return;
2020-01-08 14:26:34 -07:00
}
2020-05-06 14:14:50 -06:00
const upx = await installer.getUPX(version);
core.info('🏃 Running UPX...');
await exec.exec(`${upx} ${args} ${file}`);
2020-01-08 14:26:34 -07:00
} catch (error) {
core.setFailed(error.message);
}
}
run();