@batijs/build 0.0.251 → 0.0.252
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 +12 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { mkdir, opendir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, opendir, rm, rmdir, writeFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import "@batijs/core";
|
|
6
6
|
|
|
@@ -193,7 +193,7 @@ async function safeWriteFile(destination, content) {
|
|
|
193
193
|
});
|
|
194
194
|
await writeFile(destination, content, { encoding: "utf-8" });
|
|
195
195
|
}
|
|
196
|
-
async function safeRmFile(destination) {
|
|
196
|
+
async function safeRmFile(destination, options) {
|
|
197
197
|
try {
|
|
198
198
|
await rm(destination, {
|
|
199
199
|
force: true,
|
|
@@ -201,6 +201,15 @@ async function safeRmFile(destination) {
|
|
|
201
201
|
recursive: false,
|
|
202
202
|
retryDelay: 150
|
|
203
203
|
});
|
|
204
|
+
if (options?.removeEmptyDir) {
|
|
205
|
+
try {
|
|
206
|
+
await rmdir(path.dirname(destination), {
|
|
207
|
+
maxRetries: 3,
|
|
208
|
+
retryDelay: 150
|
|
209
|
+
});
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
}
|
|
204
213
|
} catch {
|
|
205
214
|
console.warn(`Failed to remove unecessary file: ${destination}`);
|
|
206
215
|
}
|
|
@@ -309,7 +318,7 @@ Please report this issue to https://github.com/vikejs/bati`
|
|
|
309
318
|
}
|
|
310
319
|
for (const target of filesContainingIncludeIfImported) {
|
|
311
320
|
if (!allImports.has(target)) {
|
|
312
|
-
await safeRmFile(target);
|
|
321
|
+
await safeRmFile(target, { removeEmptyDir: true });
|
|
313
322
|
}
|
|
314
323
|
}
|
|
315
324
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.252",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/node": "^18.19.14",
|
|
12
12
|
"tsup": "^8.2.4",
|
|
13
|
-
"@batijs/compile": "0.0.
|
|
13
|
+
"@batijs/compile": "0.0.252"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@batijs/core": "0.0.
|
|
16
|
+
"@batijs/core": "0.0.252"
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"module": "./dist/index.js",
|