rs-cargo/src/main.ts

40 lines
932 B
TypeScript
Raw Normal View History

2020-03-25 07:40:28 +02:00
import path from "path";
2020-03-25 07:40:28 +02:00
import * as core from "@actions/core";
2019-09-12 23:48:44 +03:00
2020-03-25 07:40:28 +02:00
import * as input from "./input";
import { Cargo, Cross } from "@actions-rs/core";
2019-09-12 23:48:44 +03:00
export async function run(actionInput: input.Input): Promise<void> {
2019-09-12 23:48:44 +03:00
let program;
if (actionInput.useCross) {
program = await Cross.getOrInstall();
2019-09-12 23:48:44 +03:00
} else {
program = await Cargo.get();
2019-09-12 23:48:44 +03:00
}
let args: string[] = [];
2019-09-12 23:48:44 +03:00
if (actionInput.toolchain) {
args.push(`+${actionInput.toolchain}`);
}
args.push(actionInput.command);
2019-09-12 23:48:44 +03:00
args = args.concat(actionInput.args);
await program.call(args);
}
async function main(): Promise<void> {
2020-03-25 07:40:28 +02:00
const matchersPath = path.join(__dirname, ".matchers");
console.log(`::add-matcher::${path.join(matchersPath, "rust.json")}`);
const actionInput = input.get();
2019-09-12 23:48:44 +03:00
try {
await run(actionInput);
2019-09-12 23:48:44 +03:00
} catch (error) {
core.setFailed(error.message);
}
}
main();