mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 09:21:00 +00:00
Add lts version (#17)
This commit is contained in:
parent
cf52edc461
commit
419dce7d3b
2 changed files with 32 additions and 0 deletions
|
@ -44,6 +44,9 @@ if (!tempDirectory) {
|
||||||
}
|
}
|
||||||
function getNode(versionSpec) {
|
function getNode(versionSpec) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (versionSpec.toLowerCase() === 'lts') {
|
||||||
|
versionSpec = getLtsVersion();
|
||||||
|
}
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath;
|
let toolPath;
|
||||||
toolPath = tc.find('node', versionSpec);
|
toolPath = tc.find('node', versionSpec);
|
||||||
|
@ -84,6 +87,19 @@ function getNode(versionSpec) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getNode = getNode;
|
exports.getNode = getNode;
|
||||||
|
// Schedule based off https://nodejs.org/en/about/releases/. TODO: would be nice to automate this so we don't drift
|
||||||
|
function getLtsVersion() {
|
||||||
|
const today = new Date();
|
||||||
|
if (today < new Date(2019, 9, 22)) {
|
||||||
|
return '10.x';
|
||||||
|
}
|
||||||
|
else if (today < new Date(2020, 9, 20)) {
|
||||||
|
return '12.x';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '14.x';
|
||||||
|
}
|
||||||
|
}
|
||||||
function queryLatestMatch(versionSpec) {
|
function queryLatestMatch(versionSpec) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// node offers a json list of versions
|
// node offers a json list of versions
|
||||||
|
|
|
@ -36,6 +36,10 @@ interface INodeVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNode(versionSpec: string) {
|
export async function getNode(versionSpec: string) {
|
||||||
|
if (versionSpec.toLowerCase() === 'lts') {
|
||||||
|
versionSpec = getLtsVersion();
|
||||||
|
}
|
||||||
|
|
||||||
// check cache
|
// check cache
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('node', versionSpec);
|
toolPath = tc.find('node', versionSpec);
|
||||||
|
@ -81,6 +85,18 @@ export async function getNode(versionSpec: string) {
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Schedule based off https://nodejs.org/en/about/releases/. TODO: would be nice to automate this so we don't drift
|
||||||
|
function getLtsVersion(): string {
|
||||||
|
const today = new Date();
|
||||||
|
if (today < new Date(2019, 9, 22)) {
|
||||||
|
return '10.x';
|
||||||
|
} else if (today < new Date(2020, 9, 20)) {
|
||||||
|
return '12.x';
|
||||||
|
} else {
|
||||||
|
return '14.x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function queryLatestMatch(versionSpec: string): Promise<string> {
|
async function queryLatestMatch(versionSpec: string): Promise<string> {
|
||||||
// node offers a json list of versions
|
// node offers a json list of versions
|
||||||
let dataFileName: string;
|
let dataFileName: string;
|
||||||
|
|
Loading…
Add table
Reference in a new issue