mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2024-10-22 05:36:08 -06:00
27 lines
708 B
TypeScript
27 lines
708 B
TypeScript
|
import * as installer from './installer';
|
||
|
import * as fs from 'fs';
|
||
|
import * as core from '@actions/core';
|
||
|
import * as exec from '@actions/exec';
|
||
|
|
||
|
export async function run(silent?: boolean) {
|
||
|
try {
|
||
|
const version = core.getInput('version') || 'latest';
|
||
|
const file = core.getInput('file', {required: true});
|
||
|
const args = core.getInput('args');
|
||
|
const upx = await installer.getUPX(version);
|
||
|
|
||
|
if (!fs.existsSync(file)) {
|
||
|
core.setFailed(`⛔ File to compress not found: ${file}`);
|
||
|
}
|
||
|
|
||
|
console.log('🏃 Running UPX...');
|
||
|
await exec.exec(`${upx} ${args} ${file}`, undefined, {
|
||
|
silent: silent
|
||
|
});
|
||
|
} catch (error) {
|
||
|
core.setFailed(error.message);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
run();
|