Skip to content

Commit

Permalink
Retain environment variables while spawning child processes with bun
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 1, 2024
1 parent 7026f57 commit 370e3b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cross/utils",
"version": "0.9.3",
"version": "0.9.4",
"exports": {
".": "./mod.ts",
"./ansi": "./utils/ansi.ts",
Expand Down
3 changes: 3 additions & 0 deletions spawntest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { spawn } from "./utils/spawn.ts";

console.log(await spawn(["apt", "list"]));
3 changes: 2 additions & 1 deletion utils/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CurrentRuntime, Runtime } from "@cross/runtime";
import process, { env } from "node:process";

/**
* Represents the results of a spawned child process.
Expand Down Expand Up @@ -84,7 +85,7 @@ async function spawnBunChildProcess(
const results = await Bun.spawn({
cmd: command,
// @ts-ignore process is runtime specific
env: { ...extraEnvVars }, // Merge environment variables
env: { ...process.env, ...extraEnvVars }, // Merge environment variables
stdout: "pipe",
stderr: "pipe",
cwd,
Expand Down

0 comments on commit 370e3b4

Please sign in to comment.