mirror of
https://gitea.com/actions/setup-deno.git
synced 2024-11-23 01:45:07 +08:00
4606d5cc6f
Co-authored-by: crowlkats <crowlkats@toaxl.com>
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
import process from "node:process";
|
|
import core from "@actions/core";
|
|
import {
|
|
getDenoVersionFromFile,
|
|
parseVersionRange,
|
|
resolveVersion,
|
|
} from "./src/version.mjs";
|
|
import { install } from "./src/install.mjs";
|
|
|
|
/**
|
|
* @param {string} message
|
|
* @returns {never}
|
|
*/
|
|
function exit(message) {
|
|
core.setFailed(message);
|
|
process.exit();
|
|
}
|
|
|
|
async function main() {
|
|
try {
|
|
const denoVersionFile = core.getInput("deno-version-file");
|
|
const range = parseVersionRange(
|
|
denoVersionFile
|
|
? getDenoVersionFromFile(denoVersionFile)
|
|
: core.getInput("deno-version"),
|
|
);
|
|
|
|
if (range === null) {
|
|
exit("The passed version range is not valid.");
|
|
}
|
|
|
|
const version = await resolveVersion(range);
|
|
if (version === null) {
|
|
exit("Could not resolve a version for the given range.");
|
|
}
|
|
|
|
core.info(`Going to install ${version.kind} version ${version.version}.`);
|
|
|
|
await install(version);
|
|
|
|
core.setOutput("deno-version", version.version);
|
|
core.setOutput("release-channel", version.kind);
|
|
|
|
core.info("Installation complete.");
|
|
} catch (err) {
|
|
core.setFailed((err instanceof Error) ? err : String(err));
|
|
process.exit();
|
|
}
|
|
}
|
|
|
|
main();
|