@thi.ng/tangle 0.2.14 → 0.2.16
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/CHANGELOG.md +1 -1
- package/cli.js +3 -6
- package/package.json +17 -17
- package/tangle.js +5 -10
package/CHANGELOG.md
CHANGED
package/cli.js
CHANGED
|
@@ -43,11 +43,9 @@ const showUsage = () => {
|
|
|
43
43
|
};
|
|
44
44
|
try {
|
|
45
45
|
const result = parse(argOpts, process.argv, { start: 3, usageOpts });
|
|
46
|
-
if (!result)
|
|
47
|
-
process.exit(1);
|
|
46
|
+
if (!result) process.exit(1);
|
|
48
47
|
const { result: opts, rest } = result;
|
|
49
|
-
if (!rest.length)
|
|
50
|
-
showUsage();
|
|
48
|
+
if (!rest.length) showUsage();
|
|
51
49
|
let ctx = {
|
|
52
50
|
logger: new ConsoleLogger("tangle", opts.debug ? "DEBUG" : "INFO"),
|
|
53
51
|
opts: {
|
|
@@ -61,8 +59,7 @@ try {
|
|
|
61
59
|
writeText(out, ctx.outputs[out], ctx.logger, opts.dryRun);
|
|
62
60
|
}
|
|
63
61
|
} catch (e) {
|
|
64
|
-
if (!(e instanceof ParseError))
|
|
65
|
-
process.stderr.write(e.message);
|
|
62
|
+
if (!(e instanceof ParseError)) process.stderr.write(e.message);
|
|
66
63
|
process.exit(1);
|
|
67
64
|
}
|
|
68
65
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/tangle",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Literate programming code block tangling / codegen utility, inspired by org-mode & noweb",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@thi.ng/api": "^8.11.
|
|
41
|
-
"@thi.ng/args": "^2.3.
|
|
42
|
-
"@thi.ng/checks": "^3.6.
|
|
43
|
-
"@thi.ng/compare": "^2.3.
|
|
44
|
-
"@thi.ng/date": "^2.7.
|
|
45
|
-
"@thi.ng/errors": "^2.5.
|
|
46
|
-
"@thi.ng/file-io": "^2.1.
|
|
47
|
-
"@thi.ng/logger": "^3.0.
|
|
48
|
-
"@thi.ng/strings": "^3.7.
|
|
49
|
-
"@thi.ng/transducers": "^9.0.
|
|
40
|
+
"@thi.ng/api": "^8.11.2",
|
|
41
|
+
"@thi.ng/args": "^2.3.33",
|
|
42
|
+
"@thi.ng/checks": "^3.6.4",
|
|
43
|
+
"@thi.ng/compare": "^2.3.5",
|
|
44
|
+
"@thi.ng/date": "^2.7.18",
|
|
45
|
+
"@thi.ng/errors": "^2.5.7",
|
|
46
|
+
"@thi.ng/file-io": "^2.1.2",
|
|
47
|
+
"@thi.ng/logger": "^3.0.12",
|
|
48
|
+
"@thi.ng/strings": "^3.7.33",
|
|
49
|
+
"@thi.ng/transducers": "^9.0.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@microsoft/api-extractor": "^7.43.
|
|
53
|
-
"@thi.ng/testament": "^0.4.
|
|
54
|
-
"esbuild": "^0.
|
|
55
|
-
"typedoc": "^0.25.
|
|
56
|
-
"typescript": "^5.4.
|
|
52
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
53
|
+
"@thi.ng/testament": "^0.4.29",
|
|
54
|
+
"esbuild": "^0.21.1",
|
|
55
|
+
"typedoc": "^0.25.13",
|
|
56
|
+
"typescript": "^5.4.5"
|
|
57
57
|
},
|
|
58
58
|
"keywords": [
|
|
59
59
|
"codegen",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"status": "alpha",
|
|
94
94
|
"year": 2022
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
97
97
|
}
|
package/tangle.js
CHANGED
|
@@ -38,8 +38,7 @@ const extractBlocks = (src, { format, logger }) => {
|
|
|
38
38
|
start
|
|
39
39
|
);
|
|
40
40
|
const matchSuffix = suffix.exec(src.substring(start));
|
|
41
|
-
if (!matchSuffix)
|
|
42
|
-
illegalState("no codeblock end found");
|
|
41
|
+
if (!matchSuffix) illegalState("no codeblock end found");
|
|
43
42
|
const end = start + matchSuffix.index;
|
|
44
43
|
const matchEnd = end + matchSuffix[0].length + 1;
|
|
45
44
|
logger.debug(
|
|
@@ -68,8 +67,7 @@ const extractBlocks = (src, { format, logger }) => {
|
|
|
68
67
|
return blocks;
|
|
69
68
|
};
|
|
70
69
|
const resolveBlock = (block, ref, ctx) => {
|
|
71
|
-
if (block.resolved)
|
|
72
|
-
return;
|
|
70
|
+
if (block.resolved) return;
|
|
73
71
|
if (block.noweb === "no") {
|
|
74
72
|
block.resolved = true;
|
|
75
73
|
return;
|
|
@@ -96,8 +94,7 @@ const resolveBlock = (block, ref, ctx) => {
|
|
|
96
94
|
childID = childID.replace("#", "");
|
|
97
95
|
childBlock = ref.blocks[childID];
|
|
98
96
|
}
|
|
99
|
-
if (!childBlock)
|
|
100
|
-
throw new UnknownBlockError([childID, block.id]);
|
|
97
|
+
if (!childBlock) throw new UnknownBlockError([childID, block.id]);
|
|
101
98
|
resolveBlock(childBlock, ref, ctx);
|
|
102
99
|
const newBody = isPlainObject(params) ? parametricBody(childBlock.body, params) : childBlock.body;
|
|
103
100
|
block.body = block.body.replace(`<<${match[1]}>>`, newBody);
|
|
@@ -113,12 +110,10 @@ const resolveBlocks = (ref, ctx) => {
|
|
|
113
110
|
return ref;
|
|
114
111
|
};
|
|
115
112
|
const parseFileMeta = (src) => {
|
|
116
|
-
if (!src.startsWith("---\n"))
|
|
117
|
-
return {};
|
|
113
|
+
if (!src.startsWith("---\n")) return {};
|
|
118
114
|
const res = {};
|
|
119
115
|
for (let line of split(src.substring(4))) {
|
|
120
|
-
if (line === "---")
|
|
121
|
-
break;
|
|
116
|
+
if (line === "---") break;
|
|
122
117
|
const [key, val] = line.split(/:\s+/g);
|
|
123
118
|
res[key.trim()] = val.trim();
|
|
124
119
|
}
|