fix(hooks): prevent console window flash on Windows (#167)

On Windows, the detached spawn option creates a visible console window.
Combined with npm (which is a .cmd batch file), this causes a brief
window flash that steals focus from the user's terminal.

- Remove detached: true (not needed, child.unref() handles non-blocking)
- Add windowsHide: true to both spawn() and inner execSync()
This commit is contained in:
superresistant
2026-01-19 21:50:30 +01:00
committed by GitHub
parent 99362f1e5f
commit 3fb6bfbb50

View File

@@ -17,7 +17,7 @@ if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir, { recursive: true }); fs.mkdirSync(cacheDir, { recursive: true });
} }
// Run check in background (spawn detached process) // Run check in background (spawn background process, windowsHide prevents console flash)
const child = spawn(process.execPath, ['-e', ` const child = spawn(process.execPath, ['-e', `
const fs = require('fs'); const fs = require('fs');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
@@ -32,7 +32,7 @@ const child = spawn(process.execPath, ['-e', `
let latest = null; let latest = null;
try { try {
latest = execSync('npm view get-shit-done-cc version', { encoding: 'utf8', timeout: 10000 }).trim(); latest = execSync('npm view get-shit-done-cc version', { encoding: 'utf8', timeout: 10000, windowsHide: true }).trim();
} catch (e) {} } catch (e) {}
const result = { const result = {
@@ -44,8 +44,8 @@ const child = spawn(process.execPath, ['-e', `
fs.writeFileSync(cacheFile, JSON.stringify(result)); fs.writeFileSync(cacheFile, JSON.stringify(result));
`], { `], {
detached: true, stdio: 'ignore',
stdio: 'ignore' windowsHide: true
}); });
child.unref(); child.unref();