Skip to content

Commit aad0749

Browse files
committed
switch Bun.spawn to child_process spawn
1 parent 94dcd01 commit aad0749

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

cli-core/src/index.ts

+25-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "./side-effects"; // doesn't quite work for silencing the bigint error me
22
import evm from "@wormhole-foundation/sdk/platforms/evm";
33
import solana from "@wormhole-foundation/sdk/platforms/solana";
44
import { encoding } from '@wormhole-foundation/sdk-connect';
5-
import { execSync } from "child_process";
5+
import { execSync, spawn } from "child_process";
66

77
import evmDeployFile from "../../evm/script/DeployWormholeNtt.s.sol" with { type: "file" };
88
import evmDeployFileHelper from "../../evm/script/helpers/DeployWormholeNttBase.sol" with { type: "file" };
@@ -1349,20 +1349,26 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
13491349
// build the program
13501350
// TODO: build with docker
13511351
checkAnchorVersion();
1352-
const proc = Bun.spawn(
1352+
const proc = spawn(
13531353
["anchor",
13541354
"build",
13551355
"-p", "example_native_token_transfers",
13561356
"--", "--no-default-features", "--features", cargoNetworkFeature(ch.network)
1357-
], {
1357+
].join(" "), {
13581358
cwd: `${pwd}/solana`
13591359
});
13601360

13611361
// const _out = await new Response(proc.stdout).text();
1362-
1363-
await proc.exited;
1364-
if (proc.exitCode !== 0) {
1365-
process.exit(proc.exitCode ?? 1);
1362+
const buildProcExitCode = await new Promise<number | null>( (resolve) => {
1363+
proc.on('exit', (code) => {
1364+
resolve(code);
1365+
})
1366+
proc.on('close', (code) => {
1367+
resolve(code);
1368+
})
1369+
})
1370+
if (buildProcExitCode !== 0) {
1371+
process.exit(buildProcExitCode?? 1);
13661372
}
13671373

13681374
binary = `${pwd}/solana/target/deploy/example_native_token_transfers.so`;
@@ -1395,14 +1401,20 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
13951401
deployCommand.push("--with-compute-unit-price", priorityFee.toString());
13961402
}
13971403

1398-
const deployProc = Bun.spawn(deployCommand);
1404+
const deployProc = spawn(deployCommand.join(" "));
13991405

14001406
const out = await new Response(deployProc.stdout).text();
1407+
const deployProcExitCode = await new Promise<number | null>( (resolve) => {
1408+
deployProc.on('exit', (code) => {
1409+
resolve(code);
1410+
})
1411+
deployProc.on('close', (code) => {
1412+
resolve(code);
1413+
})
1414+
})
14011415

1402-
await deployProc.exited;
1403-
1404-
if (deployProc.exitCode !== 0) {
1405-
process.exit(deployProc.exitCode ?? 1);
1416+
if (deployProcExitCode !== 0) {
1417+
process.exit(deployProcExitCode ?? 1);
14061418
}
14071419

14081420
// success. remove buffer.json
@@ -1705,7 +1717,7 @@ async function pullChainConfig<N extends Network, C extends Chain>(
17051717
const nativeManagerAddress = canonicalAddress(manager);
17061718

17071719
const { ntt, addresses }: { ntt: Ntt<N, C>; addresses: Partial<Ntt.Contracts>; } =
1708-
await nttFromManager<N, C>(ch, nativeManagerAddress);
1720+
await nttFromManager<N, C>(ch, nativeManagerAddress);
17091721

17101722
const mode = await ntt.getMode();
17111723
const outboundLimit = await ntt.getOutboundLimit();

0 commit comments

Comments
 (0)