Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (45 loc) · 1.58 KB
/
Copy pathindex.js
File metadata and controls
53 lines (45 loc) · 1.58 KB
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
const nodevu = require('@nodevu/core');
/**
* Finds the newest LTS or security release of a release line.
*
* @param {string} name The release line, such as `'v16'` or `'v0.10'`.
* @param {'lts' | 'security'} type Which kind of release to find.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>} The version without its `v`, or
* `undefined` when the line has no such release.
*/
async function newest(name, type, options) {
const data = await nodevu(options);
// release lines without LTS (odd lines, or lines missing from schedule.json)
// and unknown release lines don't have this data, so return undefined
// instead of throwing
if (type === 'lts') {
return data[name]?.support?.lts?.newest;
}
if (type === 'security') {
return data[name]?.security?.newest;
}
}
/**
* Finds the newest LTS release of a release line.
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
*/
async function lts(name, options) {
return await newest(name, 'lts', options);
}
/**
* Finds the newest security release of a release line.
*
* @param {string} name The release line, such as `'v16'`.
* @param {import('@nodevu/core').Options} [options] Passed to `@nodevu/core`.
* @returns {Promise<string | undefined>}
*/
async function security(name, options) {
return await newest(name, 'security', options);
}
module.exports.newest = newest;
module.exports.lts = lts;
module.exports.security = security;