-
Notifications
You must be signed in to change notification settings - Fork 40
/
main.js
56 lines (46 loc) · 1.21 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const process = require("process");
const core = require("@actions/core");
const {
parseVersionRange,
getDenoVersionFromFile,
resolveVersion,
} = require("./src/version.js");
const { install } = require("./src/install.js");
/**
* @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.isCanary ? "canary" : "stable"
} version ${version.version}.`,
);
await install(version);
core.setOutput("deno-version", version.version);
core.setOutput("is-canary", version.isCanary);
core.info("Installation complete.");
} catch (err) {
core.setFailed(err);
process.exit();
}
}
main();