mirror of
https://github.com/actions/toolkit.git
synced 2026-08-28 00:00:25 +02:00
tests(exec): use platform-aware spawn options in spawn-wait-for-file script (detach on Unix, hide window on Windows)
This commit is contained in:
@@ -24,11 +24,23 @@ if (!filePath) {
|
|||||||
|
|
||||||
const waitScript = path.join(__dirname, 'wait-for-file.js')
|
const waitScript = path.join(__dirname, 'wait-for-file.js')
|
||||||
const waitArgs = [waitScript, `file=${filePath}`]
|
const waitArgs = [waitScript, `file=${filePath}`]
|
||||||
const waitProcess = childProcess.spawn(process.execPath, waitArgs, {
|
|
||||||
stdio: 'inherit',
|
|
||||||
detached: false
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Spawn with inherited stdio and detached on Unix, non-detached on Windows
|
||||||
|
// This keeps the streams open after parent exits
|
||||||
|
const isWindows = process.platform === 'win32'
|
||||||
|
const spawnOptions = {
|
||||||
|
stdio: 'inherit',
|
||||||
|
detached: !isWindows
|
||||||
|
}
|
||||||
|
|
||||||
|
// On Windows, we need to hide the window
|
||||||
|
if (isWindows) {
|
||||||
|
spawnOptions.windowsHide = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const waitProcess = childProcess.spawn(process.execPath, waitArgs, spawnOptions)
|
||||||
|
|
||||||
|
// Unref so parent doesn't wait for child
|
||||||
waitProcess.unref()
|
waitProcess.unref()
|
||||||
|
|
||||||
if (args.stderr === 'true') {
|
if (args.stderr === 'true') {
|
||||||
|
|||||||
Reference in New Issue
Block a user