-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathts-node-wrapper.mjs
More file actions
37 lines (33 loc) · 924 Bytes
/
ts-node-wrapper.mjs
File metadata and controls
37 lines (33 loc) · 924 Bytes
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
/*
* The new --experimental-strip-types node option conflicts with `ts-node`.
* This wrapper disables it if it's supported by the current node version.
*
* See: https://github.com/TypeStrong/ts-node/issues/2152
*
* TODO: switch to native typescript support once node<22 are dropped.
*/
import {execFileSync} from 'node:child_process';
try {
execFileSync(process.execPath, ['--no-experimental-strip-types', '-e', 'undefined'], {
stdio: 'ignore',
});
if (process.env.NODE_OPTIONS === undefined) {
process.env.NODE_OPTIONS = '--no-experimental-strip-types';
} else {
process.env.NODE_OPTIONS += ' --no-experimental-strip-types';
}
} catch (_) {
// ignore
}
try {
execFileSync('ts-node', process.argv.slice(2), {
shell: process.platform === 'win32',
stdio: 'inherit',
});
} catch (error) {
if (error.code) {
throw error;
} else {
process.exitCode = error.status;
}
}