Use TypeScript and NCC

This commit is contained in:
mtkennerly 2020-07-10 20:59:22 -04:00
parent 93bf7071ee
commit 9673b0868c
7 changed files with 492 additions and 6 deletions

37
src/index.ts Normal file
View file

@ -0,0 +1,37 @@
const core = require("@actions/core");
const { execSync } = require("child_process");
function runCommand(command: string): Buffer {
console.log(`Running command: ${command}`);
return execSync(command);
}
function main() {
const install = core.getInput("install");
const envVar = core.getInput("env-var");
const command = core.getInput("command");
const args = core.getInput("args");
if (install === "none") {
// No install.
} else if (install === "latest") {
runCommand("pip install dunamai");
} else {
runCommand(`pip install dunamai==${install}`);
}
const version = runCommand(`${command} ${args}`).toString();
core.setOutput("version", version);
console.log(`Dynamic version: ${version}`);
if (envVar !== "") {
console.log(`Setting environment variable: ${envVar}`);
core.exportVariable(envVar, version);
}
}
try {
main();
} catch (error) {
core.setFailed(error.message);
}