mirror of https://github.com/garrytan/gstack.git
fix: hide the detached server windows too (folds in #1863)
This commit is contained in:
parent
92d987e600
commit
4d30746a1b
|
|
@ -326,7 +326,7 @@ async function startServer(extraEnv?: Record<string, string>): Promise<ServerSta
|
|||
const launcherCode =
|
||||
`const{spawn}=require('child_process');` +
|
||||
`spawn(process.execPath,[${JSON.stringify(NODE_SERVER_SCRIPT)}],` +
|
||||
`{detached:true,stdio:['ignore','ignore','ignore'],env:Object.assign({},process.env,` +
|
||||
`{detached:true,windowsHide:true,stdio:['ignore','ignore','ignore'],env:Object.assign({},process.env,` +
|
||||
`${extraEnvStr})}).unref()`;
|
||||
const proc = nodeSpawnSync('node', ['-e', launcherCode], {
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
|
|
@ -347,6 +347,7 @@ async function startServer(extraEnv?: Record<string, string>): Promise<ServerSta
|
|||
// the Windows path's rationale — same root cause, different OS API.
|
||||
nodeSpawn('bun', ['run', SERVER_SCRIPT], {
|
||||
detached: true,
|
||||
windowsHide: true,
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
env: { ...process.env, BROWSE_STATE_FILE: config.stateFile, BROWSE_PARENT_PID: parentPid, ...extraEnv },
|
||||
}).unref();
|
||||
|
|
|
|||
|
|
@ -61,3 +61,22 @@ describe('#1784 Windows console flash suppression', () => {
|
|||
expect(hiddenIcaclsCalls).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('detached server spawns carry windowsHide (#1863 fold-in)', () => {
|
||||
test('Windows Node launcher inner spawn carries windowsHide:true', () => {
|
||||
const body = read(CLI);
|
||||
expect(body).toMatch(/spawn\(process\.execPath,[\s\S]{0,500}detached:true,windowsHide:true/);
|
||||
});
|
||||
|
||||
test('non-Windows server nodeSpawn carries windowsHide:true', () => {
|
||||
const body = read(CLI);
|
||||
expect(body).toMatch(/nodeSpawn\('bun',[\s\S]{0,500}detached:\s*true[\s\S]{0,100}windowsHide:\s*true/);
|
||||
});
|
||||
|
||||
test('every detached spawn site in cli.ts carries windowsHide:true', () => {
|
||||
const body = read(CLI);
|
||||
const detachedSpawns = body.match(/detached:\s*true/g)?.length ?? 0;
|
||||
const windowsHideFlags = body.match(/windowsHide:\s*true/g)?.length ?? 0;
|
||||
expect(windowsHideFlags).toBeGreaterThanOrEqual(detachedSpawns);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue