@danielx/civet 0.4.18 → 0.4.19-pre.0
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/README.md +6 -1
- package/dist/browser.js +225 -135
- package/dist/civet +40 -12
- package/dist/main.js +225 -135
- package/package.json +1 -1
package/dist/civet
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
3
|
+
var compile, encoding, fs, generate, parse, prune, readLines, readline;
|
|
4
4
|
if (process.argv.includes("--version")) {
|
|
5
5
|
process.stdout.write(require("../package.json").version + "\n");
|
|
6
6
|
process.exit(0);
|
|
@@ -8,15 +8,43 @@ if (process.argv.includes("--version")) {
|
|
|
8
8
|
({ parse, compile, generate } = require("./main"));
|
|
9
9
|
({ prune } = generate);
|
|
10
10
|
encoding = "utf8";
|
|
11
|
+
process.stdin.setEncoding(encoding);
|
|
11
12
|
fs = require("fs");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
readline = require("node:readline");
|
|
14
|
+
readLines = function(rl) {
|
|
15
|
+
return new Promise(function(resolve, reject) {
|
|
16
|
+
var parts;
|
|
17
|
+
parts = [];
|
|
18
|
+
rl.on("line", function(buffer) {
|
|
19
|
+
return parts.push(buffer + "\n");
|
|
20
|
+
});
|
|
21
|
+
rl.on("SIGINT", function() {
|
|
22
|
+
rl.write("^C\n");
|
|
23
|
+
return reject();
|
|
24
|
+
});
|
|
25
|
+
return rl.on("close", function() {
|
|
26
|
+
return resolve(parts.join(""));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
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");
|
|
34
|
+
inlineMap = process.argv.includes("--inline-map");
|
|
35
|
+
filename = "unknown";
|
|
36
|
+
try {
|
|
37
|
+
filename = fs.realpathSync("/dev/stdin");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
}
|
|
40
|
+
if (ast) {
|
|
41
|
+
ast = prune(parse(input, { filename }));
|
|
42
|
+
process.stdout.write(JSON.stringify(ast, null, 2));
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
output = compile(input, { filename, js, inlineMap });
|
|
46
|
+
return process.stdout.write(output);
|
|
47
|
+
}).catch(function(e) {
|
|
48
|
+
console.error(e.message);
|
|
49
|
+
return process.exit(1);
|
|
50
|
+
});
|