Skip to content

Commit e4f4991

Browse files
authored
Merge pull request #391 from underctrl-io/node-args
feat: forward node args env
2 parents 6c237fa + 7641e58 commit e4f4991

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

packages/commandkit/src/cli/app-process.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,39 @@ export function createAppProcess(
3131

3232
const stdio = getStdio(isDev) as IOType[];
3333

34-
const ps = spawn(
35-
'node',
36-
[
37-
`--title="CommandKit ${isDev ? 'Development' : 'Production'}"`,
38-
'--enable-source-maps',
39-
fileName,
40-
],
41-
{
42-
cwd,
43-
windowsHide: true,
44-
env: isDev ? DevEnv() : ProdEnv(),
45-
stdio,
46-
},
47-
);
34+
const baseArgs = [
35+
`--title="CommandKit ${isDev ? 'Development' : 'Production'}"`,
36+
'--enable-source-maps',
37+
];
38+
39+
const nodeOptions = process.env.NODE_OPTIONS;
40+
let nodeArgs = [...baseArgs];
41+
42+
if (nodeOptions) {
43+
const options = nodeOptions.trim().split(/\s+/);
44+
45+
for (const option of options) {
46+
const optionName = option.split('=')[0];
47+
const existingIndex = nodeArgs.findIndex((arg) =>
48+
arg.startsWith(optionName),
49+
);
50+
51+
if (existingIndex !== -1) {
52+
nodeArgs[existingIndex] = option;
53+
} else {
54+
nodeArgs.push(option);
55+
}
56+
}
57+
}
58+
59+
nodeArgs.push(fileName);
60+
61+
const ps = spawn('node', nodeArgs, {
62+
cwd,
63+
windowsHide: true,
64+
env: isDev ? DevEnv() : ProdEnv(),
65+
stdio,
66+
});
4867

4968
ps.stdout?.pipe(process.stdout);
5069
ps.stderr?.pipe(process.stderr);

0 commit comments

Comments
 (0)