forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-node-version.mjs
More file actions
41 lines (34 loc) · 1.01 KB
/
Copy pathcheck-node-version.mjs
File metadata and controls
41 lines (34 loc) · 1.01 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
#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const PATH_TO_NVMRC = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'..',
'.nvmrc'
);
const nvmrc = fs.readFileSync(PATH_TO_NVMRC, 'utf8');
const minimumVersionMajor = parseInt(nvmrc.trim(), 10);
const currentVersion = process.version.replace('v', '');
const currentVersionMajor = parseInt(currentVersion.split('.')[0], 10);
const usesMinimumVersion = currentVersionMajor >= minimumVersionMajor;
if (usesMinimumVersion) {
process.exit();
}
console.error(
'' +
'Error: You are using Node.js version ' +
currentVersion +
', but you need ' +
'Node.js version ' +
minimumVersionMajor +
' or higher to build and/or test axe-core.' +
'\n\n' +
'Install Node.js version ' +
minimumVersionMajor +
' or higher and try again.' +
'\n\n' +
'You can use nvm (https://github.com/creationix/nvm) to update your Node.js version ' +
''
);
process.exit(1);