mirror of
https://github.com/actions-rs/cargo.git
synced 2025-08-14 20:55:14 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
const path = require('path');
|
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as input from './input';
|
|
import {Cargo, Cross} from '@actions-rs/core';
|
|
|
|
export async function run(actionInput: input.Input): Promise<void> {
|
|
let program;
|
|
if (actionInput.useCross) {
|
|
program = await Cross.getOrInstall();
|
|
} else {
|
|
program = await Cargo.get();
|
|
}
|
|
|
|
let args: string[] = [];
|
|
if (actionInput.toolchain) {
|
|
args.push(`+${actionInput.toolchain}`);
|
|
}
|
|
args.push(actionInput.command);
|
|
args = args.concat(actionInput.args);
|
|
|
|
await program.call(args);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
const actionInput = input.get();
|
|
|
|
const matchersPath = path.join(__dirname, '.matchers');
|
|
console.log(`::add-matcher::${path.join(matchersPath, 'rust.json')}`);
|
|
// Enabling `rustfmt` problem matcher only if `cargo fmt` is called
|
|
if (actionInput.command == 'fmt') {
|
|
console.log(`::add-matcher::${path.join(matchersPath, 'rustfmt.json')}`);
|
|
}
|
|
|
|
try {
|
|
await run(actionInput);
|
|
} catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
}
|
|
|
|
main();
|