@danielx/civet 0.4.19-pre.1 → 0.4.19-pre.11

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
@@ -5,12 +5,40 @@ if (process.argv.includes("--version")) {
5
5
  process.stdout.write(require("../package.json").version + "\n");
6
6
  process.exit(0);
7
7
  }
8
+ if (process.argv.includes("--help")) {
9
+ process.stdout.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
10
+ \u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
11
+ \u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
12
+ \u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
13
+ \xB7\u2580\u2580\u2580 \u2580\u2580\u2580. \u2580 \u2580\u2580\u2580 \u2580\u2580\u2580 \`- \\\`_\`"'-
14
+
15
+
16
+ Usage:
17
+
18
+ civet [options] < input.civet > output.ts
19
+
20
+ Options:
21
+ --help Show this help message
22
+ --version Show the version number
23
+ --ast Output the AST instead of the compiled code
24
+ --inline-map Generate a sourcemap
25
+ --js Strip out all type annotations
26
+
27
+ `);
28
+ process.exit(0);
29
+ }
8
30
  ({ parse, compile, generate } = require("./main"));
9
31
  ({ prune } = generate);
10
32
  encoding = "utf8";
11
33
  process.stdin.setEncoding(encoding);
12
34
  fs = require("fs");
13
- readline = require("node:readline");
35
+ readline = function() {
36
+ try {
37
+ return require("node:readline");
38
+ } catch (error) {
39
+ return require("readline");
40
+ }
41
+ }();
14
42
  readLines = function(rl) {
15
43
  return new Promise(function(resolve, reject) {
16
44
  var parts;
@@ -28,23 +56,22 @@ readLines = function(rl) {
28
56
  });
29
57
  };
30
58
  readLines(readline.createInterface(process.stdin)).then(function(input) {
31
- var ast, filename, inlineMap, js, output;
32
- process.argv.includes("--ast");
33
- js = process.argv.includes("--js");
59
+ var ast, cache, filename, inlineMap, js, output;
60
+ ast = process.argv.includes("--ast");
61
+ cache = !process.argv.includes("--no-cache");
34
62
  inlineMap = process.argv.includes("--inline-map");
63
+ js = process.argv.includes("--js");
35
64
  filename = "unknown";
36
65
  try {
37
66
  filename = fs.realpathSync("/dev/stdin");
38
67
  } catch (error) {
39
68
  }
69
+ output = compile(input, { ast, cache, filename, inlineMap, js });
40
70
  if (ast) {
41
- ast = prune(parse(input, { filename }));
42
- process.stdout.write(JSON.stringify(ast, null, 2));
43
- process.exit(0);
71
+ output = JSON.stringify(output, null, 2);
44
72
  }
45
- output = compile(input, { filename, js, inlineMap });
46
73
  return process.stdout.write(output);
47
74
  }).catch(function(e) {
48
- console.error(e.message);
75
+ console.error(e);
49
76
  return process.exit(1);
50
77
  });
package/dist/esm.mjs CHANGED
@@ -36,7 +36,7 @@ function normalizeSlashes(value) {
36
36
  }
37
37
 
38
38
  function ensureRegister () {
39
- if (registered)return
39
+ if (registered) { return }
40
40
 
41
41
  const installation = {
42
42
  environment: 'node',