forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forward IPC to child process if running package script (oven-sh#13934)
Co-authored-by: Jarred Sumner <[email protected]>
- Loading branch information
1 parent
3c2e798
commit b9a5e44
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { spawn, spawnSync, env } from "bun"; | ||
import fs from "node:fs/promises"; | ||
import { describe, expect, it } from "bun:test"; | ||
import { bunExe, isWindows } from "harness"; | ||
import path from "path"; | ||
|
||
it.todoIf(isWindows)("spawning a bun package script should inherit the ipc fd", async () => { | ||
await fs.writeFile( | ||
path.join(process.cwd(), "package.json"), | ||
JSON.stringify({ | ||
scripts: { | ||
test: `${bunExe()} -e 'process.send("hello")'`, | ||
}, | ||
}), | ||
); | ||
|
||
let testMessage; | ||
|
||
const child = spawn([bunExe(), "run", "test"], { | ||
ipc: message => { | ||
testMessage = message; | ||
}, | ||
stdio: ["inherit", "inherit", "inherit"], | ||
}); | ||
|
||
await child.exited; | ||
expect(testMessage).toBe("hello"); | ||
}); |