flashtrace 0.7.0 → 0.7.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/flashtrace.mjs +27 -8
- package/package.json +1 -1
package/dist/flashtrace.mjs
CHANGED
|
@@ -24,6 +24,9 @@ var cLike = { line: ["//"], block: [["/*", "*/"]] };
|
|
|
24
24
|
var cLikeNested = { line: ["//"], block: [["/*", "*/", true]] };
|
|
25
25
|
var php = { line: ["//", "#"], block: [["/*", "*/"]] };
|
|
26
26
|
var hash = { line: ["#"], block: [] };
|
|
27
|
+
var coffee = { line: ["#"], block: [["###", "###"]] };
|
|
28
|
+
var julia = { line: ["#"], block: [["#=", "=#", true]] };
|
|
29
|
+
var nim = { line: ["#"], block: [["#[", "]#", true], ["##[", "]##", true]] };
|
|
27
30
|
var powershell = { line: ["#"], block: [["<#", "#>"]] };
|
|
28
31
|
var sql = { line: ["--"], block: [["/*", "*/"]] };
|
|
29
32
|
var lua = { line: ["--"], block: [["--[[", "]]"]] };
|
|
@@ -32,6 +35,7 @@ var css = { line: [], block: [["/*", "*/"]] };
|
|
|
32
35
|
var xml = { line: [], block: [["<!--", "-->"]] };
|
|
33
36
|
var none = { line: [], block: [] };
|
|
34
37
|
var semicolon = { line: [";"], block: [] };
|
|
38
|
+
var scheme = { line: [";"], block: [["#|", "|#", true]] };
|
|
35
39
|
var percent = { line: ["%"], block: [] };
|
|
36
40
|
var dashLine = { line: ["--"], block: [] };
|
|
37
41
|
var ml = { line: [], block: [["(*", "*)", true]] };
|
|
@@ -46,7 +50,7 @@ function scriptGrammar(tag) {
|
|
|
46
50
|
const type = attrOf(tag, "type");
|
|
47
51
|
if (/json|importmap/.test(type)) return none;
|
|
48
52
|
if (/template|html/.test(type)) return xml;
|
|
49
|
-
if (/coffee/.test(attrOf(tag, "lang"))) return
|
|
53
|
+
if (/coffee/.test(attrOf(tag, "lang"))) return coffee;
|
|
50
54
|
return cLike;
|
|
51
55
|
}
|
|
52
56
|
function styleGrammar(tag) {
|
|
@@ -102,11 +106,12 @@ var BY_EXT = {
|
|
|
102
106
|
".ex": hash,
|
|
103
107
|
".exs": hash,
|
|
104
108
|
".tcl": hash,
|
|
105
|
-
".jl": hash,
|
|
106
|
-
".nim": hash,
|
|
107
109
|
".graphql": hash,
|
|
108
110
|
".gql": hash,
|
|
109
|
-
|
|
111
|
+
// hash line comments plus a block pair of their own
|
|
112
|
+
".jl": julia,
|
|
113
|
+
".nim": nim,
|
|
114
|
+
".coffee": coffee,
|
|
110
115
|
".ps1": powershell,
|
|
111
116
|
".psm1": powershell,
|
|
112
117
|
".tf": hcl,
|
|
@@ -119,8 +124,10 @@ var BY_EXT = {
|
|
|
119
124
|
".edn": semicolon,
|
|
120
125
|
".el": semicolon,
|
|
121
126
|
".lisp": semicolon,
|
|
122
|
-
|
|
123
|
-
".
|
|
127
|
+
// Scheme/Racket: ; lines plus nestable #| |# blocks
|
|
128
|
+
".scm": scheme,
|
|
129
|
+
".ss": scheme,
|
|
130
|
+
".rkt": scheme,
|
|
124
131
|
// percent (Erlang, LaTeX)
|
|
125
132
|
".erl": percent,
|
|
126
133
|
".hrl": percent,
|
|
@@ -894,25 +901,37 @@ Options:
|
|
|
894
901
|
-V, --version print the version number
|
|
895
902
|
-h, --help show this help
|
|
896
903
|
|
|
904
|
+
Long options also accept "="-attached values, e.g. --tags=a,b.
|
|
905
|
+
|
|
897
906
|
Exit codes: 0 clean, 1 defects or problems found, 2 usage error`;
|
|
898
907
|
function packageVersion() {
|
|
899
908
|
const pkg = new URL("../package.json", import.meta.url);
|
|
900
909
|
return JSON.parse(readFileSync(pkg, "utf8")).version;
|
|
901
910
|
}
|
|
911
|
+
function splitLongOption(token) {
|
|
912
|
+
const eq = token.startsWith("--") ? token.indexOf("=") : -1;
|
|
913
|
+
return eq === -1 ? [token, null] : [token.slice(0, eq), token.slice(eq + 1)];
|
|
914
|
+
}
|
|
915
|
+
function rejectValue(name, inline) {
|
|
916
|
+
if (inline !== null) throw new UsageError(`option ${name} does not take a value`);
|
|
917
|
+
}
|
|
902
918
|
function parseArgs(argv) {
|
|
903
919
|
const opts = { dirs: [], tags: null, verbose: false };
|
|
904
920
|
for (let i = 0; i < argv.length; i++) {
|
|
905
|
-
const a = argv[i];
|
|
921
|
+
const [a, inline] = splitLongOption(argv[i]);
|
|
906
922
|
if (a === "-h" || a === "--help") {
|
|
923
|
+
rejectValue(a, inline);
|
|
907
924
|
console.log(HELP);
|
|
908
925
|
process3.exit(0);
|
|
909
926
|
} else if (a === "-v" || a === "--verbose") {
|
|
927
|
+
rejectValue(a, inline);
|
|
910
928
|
opts.verbose = true;
|
|
911
929
|
} else if (a === "-V" || a === "--version") {
|
|
930
|
+
rejectValue(a, inline);
|
|
912
931
|
console.log(packageVersion());
|
|
913
932
|
process3.exit(0);
|
|
914
933
|
} else if (a === "-t" || a === "--tags") {
|
|
915
|
-
const v = argv[++i];
|
|
934
|
+
const v = inline ?? argv[++i];
|
|
916
935
|
if (!v) throw new UsageError(`missing value for ${a}`);
|
|
917
936
|
opts.tags = v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
918
937
|
} else if (a.startsWith("-")) {
|