-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheckCurrent.js
50 lines (45 loc) · 1.14 KB
/
checkCurrent.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
'use strict';
const colors = require('colors/safe');
const EXITS = require('./exit-codes');
const table = require('./table');
const currentVersions = {
node: process.version,
};
module.exports = async function checkCurrent(selectedEngines, rootValids, graphValids) {
let anyInvalid = false;
const rows = await Promise.all(selectedEngines.map(async (engine) => {
const currentVersion = await currentVersions[engine];
const rootValid = rootValids[engine].includes(currentVersion);
const graphValid = graphValids[engine].includes(currentVersion);
if (!rootValid || !graphValid) {
anyInvalid = true;
}
return [
colors.blue(engine),
`${colors.blue(colors.bold(currentVersion))}`,
`${colors.bold(rootValid ? colors.green('yes') : colors.red('no'))}!`,
`${colors.bold(graphValids ? colors.green('yes') : colors.red('no'))}!`,
];
}));
const output = [
'',
table([
[
'engine',
'current version',
'valid (package)',
'valid (dependency graph)',
].map((x) => colors.bold(colors.gray(x))),
...rows,
]).trim(),
];
if (anyInvalid) {
throw {
code: EXITS.CURRENT,
output,
};
}
return {
output,
};
};