Skip to content

Commit 637be54

Browse files
committed
fix: npm test now needs windows support for NODE_OPTIONS
1 parent e87f684 commit 637be54

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json",
3535
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
3636
"tsx": "tsx",
37-
"test": "tsc -p ./tsconfig.build.json && NODE_OPTIONS=--experimental-vm-modules jest",
38-
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}'",
39-
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}' --fix",
37+
"test": "node ./scripts/test.mjs",
38+
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}'",
39+
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}' --fix",
4040
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",
4141
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
4242
},
@@ -47,7 +47,6 @@
4747
"@types/node": "^18.15.0",
4848
"@typescript-eslint/eslint-plugin": "^5.61.0",
4949
"@typescript-eslint/parser": "^5.61.0",
50-
5150
"eslint": "^8.44.0",
5251
"eslint-config-prettier": "^8.8.0",
5352
"eslint-plugin-import": "^2.27.5",

scripts/test.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
3+
import os from 'node:os';
4+
import path from 'node:path';
5+
import url from 'node:url';
6+
import process from 'node:process';
7+
import childProcess from 'node:child_process';
8+
9+
const projectPath = path.dirname(
10+
path.dirname(url.fileURLToPath(import.meta.url)),
11+
);
12+
13+
const platform = os.platform();
14+
15+
/* eslint-disable no-console */
16+
async function main() {
17+
const tscArgs = [`-p`, path.join(projectPath, 'tsconfig.build.json')];
18+
console.error('Running tsc:');
19+
console.error(['tsc', ...tscArgs].join(' '));
20+
childProcess.execFileSync('tsc', tscArgs, {
21+
stdio: ['inherit', 'inherit', 'inherit'],
22+
windowsHide: true,
23+
encoding: 'utf-8',
24+
shell: platform === 'win32' ? true : false,
25+
});
26+
const jestArgs = [];
27+
console.error('Running jest:');
28+
console.error(['jest', ...jestArgs].join(' '));
29+
childProcess.execFileSync('jest', jestArgs, {
30+
env: {
31+
...process.env,
32+
NODE_OPTIONS: '--experimental-vm-modules',
33+
},
34+
stdio: ['inherit', 'inherit', 'inherit'],
35+
windowsHide: true,
36+
encoding: 'utf-8',
37+
shell: platform === 'win32' ? true : false,
38+
});
39+
}
40+
/* eslint-enable no-console */
41+
42+
if (import.meta.url.startsWith('file:')) {
43+
const modulePath = url.fileURLToPath(import.meta.url);
44+
if (process.argv[1] === modulePath) {
45+
void main();
46+
}
47+
}

0 commit comments

Comments
 (0)