Skip to content

Commit

Permalink
🐛 dynamically import node process
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Dec 18, 2024
1 parent 6cd0510 commit a8c61c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createContext } from "./context.ts";
import { type Operation } from "./types.ts";
import { action } from "./instructions.ts";
import { run } from "./run.ts";
import process from "node:process";
import { call } from "./call.ts";

/**
* Halt process execution immediately and initiate shutdown. If a message is
Expand Down Expand Up @@ -91,6 +91,9 @@ export async function main(
}
},
*node() {
let { default: process } = yield* call(() =>
import("node:process")
);
hardexit = (status) => process.exit(status);
try {
process.on("SIGINT", interrupt.SIGINT);
Expand Down Expand Up @@ -159,7 +162,7 @@ function* withHost<T>(op: HostOperation<T>): Operation<T> {
// @see https://github.com/iliakan/detect-node/blob/master/index.js
} else if (
Object.prototype.toString.call(
typeof process !== "undefined" ? process : 0,
typeof globalThis.process !== "undefined" ? globalThis.process : 0,
) === "[object process]"
) {
return yield* op.node();
Expand Down

0 comments on commit a8c61c2

Please sign in to comment.