rs-cargo/src/main.ts

40 lines
935 B
TypeScript
Raw Normal View History

const path = require('path');
2019-09-12 23:48:44 +03:00
import * as core from '@actions/core';
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> {
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();