@danielx/civet 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/civet CHANGED
@@ -228,7 +228,7 @@ async function* readFiles(filenames) {
228
228
  }
229
229
  if (process.stdin.isTTY) {
230
230
  const lines = [];
231
- const rl = (await import("readline")).createInterface(process.stdin, process.stdout);
231
+ const rl = (await import("node:readline")).createInterface(process.stdin, process.stdout);
232
232
  rl.on("line", (buffer) => lines.push(buffer + "\n"));
233
233
  content = await new Promise((resolve, reject) => {
234
234
  rl.on("SIGINT", () => {
@@ -259,11 +259,11 @@ async function* readFiles(filenames) {
259
259
  return results1;
260
260
  }
261
261
  async function repl(options) {
262
- const vm = await import("vm");
262
+ const vm = await import("node:vm");
263
263
  let importModuleDynamically = vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER;
264
264
  if (!importModuleDynamically) {
265
265
  if (vm.SourceTextModule != null) {
266
- const { pathToFileURL } = await import("url");
266
+ const { pathToFileURL } = await import("node:url");
267
267
  importModuleDynamically = (specifier) => {
268
268
  if (/^\.\.?[/\\]/.test(specifier)) {
269
269
  return import(pathToFileURL(import_path.default.join(process.cwd(), specifier)));
@@ -273,11 +273,11 @@ async function repl(options) {
273
273
  };
274
274
  } else {
275
275
  const execArgv = ["--experimental-vm-modules"];
276
- const { register } = await import("module");
276
+ const { register } = await import("node:module");
277
277
  if (process.env.NODE_OPTIONS) {
278
278
  execArgv.push(process.env.NODE_OPTIONS);
279
279
  }
280
- const { fork } = await import("child_process");
280
+ const { fork } = await import("node:child_process");
281
281
  fork(__filename, process.argv.slice(2), {
282
282
  execArgv,
283
283
  stdio: "inherit"
@@ -300,7 +300,7 @@ async function repl(options) {
300
300
  }
301
301
  })()} code.`);
302
302
  global.quit = global.exit = () => process.exit(0);
303
- const nodeRepl = await import("repl");
303
+ const nodeRepl = await import("node:repl");
304
304
  const r = nodeRepl.start({
305
305
  prompt: (() => {
306
306
  switch (false) {
@@ -500,6 +500,14 @@ async function cli() {
500
500
  errors++;
501
501
  continue;
502
502
  }
503
+ process.stdout.on("error", (e) => {
504
+ if (["EPIPE", "EOF"].includes(e.code)) {
505
+ return process.exit(0);
506
+ } else {
507
+ console.error(e);
508
+ return process.exit(1);
509
+ }
510
+ });
503
511
  if (options.ast) {
504
512
  process.stdout.write(JSON.stringify(output, null, 2));
505
513
  } else if (options.compile) {
@@ -547,8 +555,8 @@ async function cli() {
547
555
  process.exit(1);
548
556
  }
549
557
  }
550
- const { fork } = await import("child_process");
551
- const { register } = await import("module");
558
+ const { fork } = await import("node:child_process");
559
+ const { register } = await import("node:module");
552
560
  let execArgv;
553
561
  if (register) {
554
562
  execArgv = ["--import", "@danielx/civet/register"];