@danielx/civet 0.8.1 → 0.8.2

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
@@ -400,44 +400,17 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
400
400
  }
401
401
  return callback(null, output);
402
402
  }
403
+ const parseOptions = {
404
+ ...options.parseOptions,
405
+ repl: true
406
+ };
403
407
  let ast;
404
408
  try {
405
- ast = await (0, import_main.compile)(input, { ...options, filename, ast: true });
409
+ ast = await (0, import_main.compile)(input, { ...options, parseOptions, filename, ast: true });
406
410
  } catch (error) {
407
411
  showError2(error);
408
412
  return callback(null, void 0);
409
413
  }
410
- const topLevelAwait = import_main.lib.hasAwait(ast) || import_main.lib.hasImportDeclaration(ast);
411
- if (topLevelAwait) {
412
- const [prologue, rest] = (0, import_main.parse)(input, {
413
- startRule: "ProloguePrefix",
414
- filename: "--civet argument"
415
- });
416
- const prefix = input.slice(0, -rest.length);
417
- const coffee = prologue.some((p) => p.type === "CivetPrologue" && (p.config.coffeeCompat || p.config.coffeeDo));
418
- ast = await (0, import_main.compile)(
419
- prefix + (coffee ? "(do ->\n" : "async do\n") + rest.replace(/^/gm, " ") + (coffee ? ")" : ""),
420
- { ...options, filename, ast: true }
421
- );
422
- let ref1;
423
- if (coffee) {
424
- ref1 = import_main.lib.gatherRecursive(ast.children, ($) => $.type === "BlockStatement")[0];
425
- } else {
426
- ref1 = import_main.lib.gatherRecursive(ast.children, ($1) => $1.type === "DoStatement")[0].block;
427
- }
428
- ;
429
- const topBlock = ref1;
430
- for (let ref2 = topBlock.expressions, i3 = 0, len2 = ref2.length; i3 < len2; i3++) {
431
- const [, statement] = ref2[i3];
432
- if (typeof statement === "object" && statement != null && "type" in statement && statement.type === "Declaration") {
433
- statement.children.shift();
434
- if (!Array.isArray(ast)) {
435
- ast = [ast];
436
- }
437
- ast.unshift(`var ${statement.names.join(",")};`);
438
- }
439
- }
440
- }
441
414
  let errors = [];
442
415
  try {
443
416
  output = (0, import_main.generate)(ast, { ...options, errors, sourceMap: void 0 });
@@ -460,7 +433,7 @@ ${" ".repeat(error.column - 1)}^ ${error.header}`);
460
433
  } catch (error) {
461
434
  return callback(error, void 0);
462
435
  }
463
- if (topLevelAwait) {
436
+ if (ast.topLevelAwait) {
464
437
  let ok = true;
465
438
  try {
466
439
  return result = await result;
@@ -636,17 +609,17 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
636
609
  }
637
610
  }
638
611
  } else if (options.run) {
639
- let ref3;
612
+ let ref1;
640
613
  {
641
614
  if (typeof output === "string" && /\b(await|import|export)\b/.test(output)) {
642
615
  const ast = await (0, import_main.compile)(content, { ...options, ast: true, filename });
643
- ref3 = import_main.lib.hasAwait(ast) || import_main.lib.hasImportDeclaration(ast) || import_main.lib.hasExportDeclaration(ast);
616
+ ref1 = import_main.lib.hasAwait(ast) || import_main.lib.hasImportDeclaration(ast) || import_main.lib.hasExportDeclaration(ast);
644
617
  } else {
645
- ref3 = void 0;
618
+ ref1 = void 0;
646
619
  }
647
620
  }
648
621
  ;
649
- const esm = ref3;
622
+ const esm = ref1;
650
623
  if (esm) {
651
624
  if (stdin) {
652
625
  filename = `.stdin-${process.pid}.civet`;
@@ -726,9 +699,9 @@ You can override this behavior via: --civet rewriteCivetImports=.ext
726
699
  }
727
700
  }, !filenames.length);
728
701
  } catch (error) {
729
- let ref4;
730
- if (ref4 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
731
- const match = ref4;
702
+ let ref2;
703
+ if (ref2 = error.message.match(/Aborting build because of (\d+) TypeScript diagnostic/)) {
704
+ const match = ref2;
732
705
  return process.exitCode = Math.min(255, errors + +match[1]);
733
706
  } else {
734
707
  process.exitCode = 1;