@danielx/civet 0.5.22 → 0.5.23
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 +3 -0
- package/dist/civet +35 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ Civet
|
|
|
8
8
|
|
|
9
9
|
The CoffeeScript of TypeScript. Much closer to ES2015+ (for better or worse).
|
|
10
10
|
|
|
11
|
+
- [Documentation](https://civet.dev/)
|
|
11
12
|
- [Online Civet Playground](https://civet-web.vercel.app/)
|
|
12
13
|
- [Civet VSCode Extension](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
|
|
13
14
|
- [Discord Server](https://discord.gg/xkrW9GebBc)
|
|
@@ -27,6 +28,8 @@ npm install -g @danielx/civet
|
|
|
27
28
|
civet
|
|
28
29
|
# Compile civet source file to typescript
|
|
29
30
|
civet < source.civet > output.ts
|
|
31
|
+
# Execute a simple civet script (no imports)
|
|
32
|
+
civet source.civet ...args...
|
|
30
33
|
# Execute a civet source file in node using ts-node
|
|
31
34
|
node --loader ts-node/esm --loader @danielx/civet/esm source.civet
|
|
32
35
|
```
|
package/dist/civet
CHANGED
|
@@ -46,19 +46,37 @@ encoding = "utf8";
|
|
|
46
46
|
fs = require("fs/promises");
|
|
47
47
|
path = require("path");
|
|
48
48
|
parseArgs = function(args = process.argv.slice(2)) {
|
|
49
|
-
var arg, char, filenames, i, options, ref;
|
|
49
|
+
var arg, char, endOfArgs, filenames, i, options, ref, scriptArgs;
|
|
50
50
|
options = {};
|
|
51
|
+
Object.defineProperty(options, "run", {
|
|
52
|
+
get: function() {
|
|
53
|
+
return !(this.ast || this.compile);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
51
56
|
filenames = [];
|
|
57
|
+
scriptArgs = null;
|
|
52
58
|
i = 0;
|
|
59
|
+
endOfArgs = function(j) {
|
|
60
|
+
i = args.length;
|
|
61
|
+
if (j >= args.length) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (options.run) {
|
|
65
|
+
filenames.push(args[j]);
|
|
66
|
+
return scriptArgs = args.slice(j);
|
|
67
|
+
} else {
|
|
68
|
+
return filenames.push(...args.slice(j));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
53
71
|
while (i < args.length) {
|
|
54
72
|
arg = args[i];
|
|
55
73
|
if (/^-\w{2,}$/.test(arg)) {
|
|
56
74
|
splice.apply(args, [i, i - i + 1].concat(ref = function() {
|
|
57
|
-
var
|
|
75
|
+
var k, len, ref1, results;
|
|
58
76
|
ref1 = arg.slice(1);
|
|
59
77
|
results = [];
|
|
60
|
-
for (
|
|
61
|
-
char = ref1[
|
|
78
|
+
for (k = 0, len = ref1.length; k < len; k++) {
|
|
79
|
+
char = ref1[k];
|
|
62
80
|
results.push(`-${char}`);
|
|
63
81
|
}
|
|
64
82
|
return results;
|
|
@@ -87,21 +105,24 @@ parseArgs = function(args = process.argv.slice(2)) {
|
|
|
87
105
|
options.js = true;
|
|
88
106
|
break;
|
|
89
107
|
case "--":
|
|
90
|
-
|
|
91
|
-
i = args.length;
|
|
108
|
+
endOfArgs(++i);
|
|
92
109
|
break;
|
|
93
110
|
default:
|
|
94
|
-
|
|
111
|
+
if (options.run) {
|
|
112
|
+
endOfArgs(i);
|
|
113
|
+
} else {
|
|
114
|
+
filenames.push(arg);
|
|
115
|
+
}
|
|
95
116
|
}
|
|
96
117
|
i++;
|
|
97
118
|
}
|
|
98
|
-
return { filenames, options };
|
|
119
|
+
return { filenames, scriptArgs, options };
|
|
99
120
|
};
|
|
100
121
|
readFiles = async function* (filenames, options) {
|
|
101
|
-
var content, error, filename,
|
|
122
|
+
var content, error, filename, k, len, lines, results, rl, stdin;
|
|
102
123
|
results = [];
|
|
103
|
-
for (
|
|
104
|
-
filename = filenames[
|
|
124
|
+
for (k = 0, len = filenames.length; k < len; k++) {
|
|
125
|
+
filename = filenames[k];
|
|
105
126
|
stdin = filename === "-";
|
|
106
127
|
try {
|
|
107
128
|
if (stdin) {
|
|
@@ -172,8 +193,8 @@ repl = function(options) {
|
|
|
172
193
|
});
|
|
173
194
|
};
|
|
174
195
|
cli = async function() {
|
|
175
|
-
var content, error, filename, filenames, options, optionsPath, output, outputFilename, outputPath, ref, results, stat, stdin, x;
|
|
176
|
-
({ filenames, options } = parseArgs());
|
|
196
|
+
var content, error, filename, filenames, options, optionsPath, output, outputFilename, outputPath, ref, results, scriptArgs, stat, stdin, x;
|
|
197
|
+
({ filenames, scriptArgs, options } = parseArgs());
|
|
177
198
|
if (!filenames.length) {
|
|
178
199
|
options.compile = true;
|
|
179
200
|
if (process.stdin.isTTY) {
|
|
@@ -182,7 +203,6 @@ cli = async function() {
|
|
|
182
203
|
filenames = ["-"];
|
|
183
204
|
}
|
|
184
205
|
}
|
|
185
|
-
options.run = !(options.ast || options.compile);
|
|
186
206
|
if (options.run) {
|
|
187
207
|
options.js = true;
|
|
188
208
|
options.inlineMap = true;
|
|
@@ -249,6 +269,7 @@ cli = async function() {
|
|
|
249
269
|
}
|
|
250
270
|
} else {
|
|
251
271
|
module.filename = await fs.realpath(filename);
|
|
272
|
+
process.argv = ["civet", module.filename, ...scriptArgs];
|
|
252
273
|
module.paths = require("module")._nodeModulePaths(path.dirname(module.filename));
|
|
253
274
|
try {
|
|
254
275
|
results.push(module._compile(output, module.filename));
|