@batijs/build 0.0.93 → 0.0.95
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/index.js +7 -34
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
|
-
import {
|
|
3
|
+
import { mkdir, opendir, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import {
|
|
5
|
+
import { transformAndFormat } from "@batijs/core";
|
|
6
6
|
|
|
7
7
|
// src/queue.ts
|
|
8
8
|
function queue() {
|
|
@@ -28,13 +28,6 @@ function toDist(filepath, source, dist) {
|
|
|
28
28
|
split[split.length - 1] = split[split.length - 1].replace(/^\$\$?(.*)\.[tj]sx?$/, "$1");
|
|
29
29
|
return split.join(path.sep).replace(source, dist);
|
|
30
30
|
}
|
|
31
|
-
async function safeCopyFile(source, destination) {
|
|
32
|
-
const destinationDir = path.dirname(destination);
|
|
33
|
-
await mkdir(destinationDir, {
|
|
34
|
-
recursive: true
|
|
35
|
-
});
|
|
36
|
-
await copyFile(source, destination);
|
|
37
|
-
}
|
|
38
31
|
async function safeWriteFile(destination, content) {
|
|
39
32
|
const destinationDir = path.dirname(destination);
|
|
40
33
|
await mkdir(destinationDir, {
|
|
@@ -72,10 +65,6 @@ function transformFileAfterExec(filepath, fileContent) {
|
|
|
72
65
|
throw new Error(`Unsupported extension ${ext} (${filepath})`);
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
|
-
async function fileContainsBatiMeta(filepath) {
|
|
76
|
-
const code = await readFile(filepath, { encoding: "utf-8" });
|
|
77
|
-
return code.includes("import.meta.BATI_");
|
|
78
|
-
}
|
|
79
68
|
async function importTransformer(p) {
|
|
80
69
|
const importFile = isWin ? "file://" + p : p;
|
|
81
70
|
const f = await import(importFile);
|
|
@@ -117,33 +106,17 @@ Please report this issue to https://github.com/magne4000/bati`
|
|
|
117
106
|
targets.add(target);
|
|
118
107
|
}
|
|
119
108
|
});
|
|
120
|
-
} else
|
|
109
|
+
} else {
|
|
121
110
|
transformAndWriteQ.add(async () => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
filepath: p
|
|
127
|
-
});
|
|
128
|
-
} else {
|
|
129
|
-
const template = await readFile(p, { encoding: "utf-8" });
|
|
130
|
-
try {
|
|
131
|
-
fileContent = renderSquirrelly(template, meta);
|
|
132
|
-
} catch (e) {
|
|
133
|
-
console.error("SquirrellyJS error while rendering", p);
|
|
134
|
-
throw e;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
111
|
+
const code = await readFile(p, { encoding: "utf-8" });
|
|
112
|
+
const fileContent = await transformAndFormat(code, meta, {
|
|
113
|
+
filepath: p
|
|
114
|
+
});
|
|
137
115
|
if (fileContent) {
|
|
138
116
|
await safeWriteFile(target, fileContent);
|
|
139
117
|
targets.add(target);
|
|
140
118
|
}
|
|
141
119
|
});
|
|
142
|
-
} else {
|
|
143
|
-
simpleCopyQ.add(async () => {
|
|
144
|
-
await safeCopyFile(p, target);
|
|
145
|
-
targets.add(target);
|
|
146
|
-
});
|
|
147
120
|
}
|
|
148
121
|
}
|
|
149
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.95",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/node": "^16.18.40",
|
|
12
12
|
"tsup": "^7.2.0",
|
|
13
|
-
"@batijs/tsup": "0.0.
|
|
13
|
+
"@batijs/tsup": "0.0.95"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@batijs/core": "0.0.
|
|
16
|
+
"@batijs/core": "0.0.95"
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"module": "./dist/index.js",
|