forked from polarsignals/custom-labels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
36 lines (30 loc) · 1.05 KB
/
Copy pathrun.js
File metadata and controls
36 lines (30 loc) · 1.05 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
'use strict';
// `npm test` entry point.
//
// The script used to pass --experimental-async-context-frame unconditionally,
// which works on Node 22/23 and fails outright from Node 24 on, where the flag
// was removed:
//
// node: bad option: --experimental-async-context-frame
//
// so `npm test` was broken on every current Node. Compute the flags instead.
const { spawnSync } = require('node:child_process');
const path = require('node:path');
const { acfFlags } = require('./node-flags');
const major = Number(process.versions.node.split('.')[0]);
const flags = [...acfFlags()];
// --disable-warning landed in Node 21.3; on older Node it would itself be a
// bad option. Nothing below 22 can run these tests anyway (test.js bails).
if (major >= 22) {
flags.push('--disable-warning=ExperimentalWarning');
}
const res = spawnSync(
process.execPath,
[...flags, '--test', path.join(__dirname, 'test.js')],
{ stdio: 'inherit' },
);
if (res.error) {
console.error(res.error);
process.exit(1);
}
process.exit(res.status === null ? 1 : res.status);