@idomatic/core 1.1.66 ā 1.1.67
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/bin/index.js +4 -6
- package/lib/scan.js +18 -4
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import runInitScan from "../lib/scan.js";
|
|
3
|
-
import runInitScanDry from "../lib/scanDry.js";
|
|
4
3
|
|
|
5
4
|
const args = process.argv.slice(2);
|
|
5
|
+
const isDry = args[0] === "scan" && args[1] === "--dry";
|
|
6
6
|
|
|
7
|
-
if (args[0] === "scan"
|
|
8
|
-
await
|
|
9
|
-
} else if (args[0] === "scan") {
|
|
10
|
-
await runInitScan();
|
|
7
|
+
if (args[0] === "scan") {
|
|
8
|
+
await runInitScan(isDry);
|
|
11
9
|
} else {
|
|
12
|
-
console.log("Unsupported command
|
|
10
|
+
console.log("ā Unsupported command.\nš Use: 'scan' or 'scan --dry'");
|
|
13
11
|
}
|
package/lib/scan.js
CHANGED
|
@@ -2,7 +2,7 @@ import { globby } from "globby";
|
|
|
2
2
|
import { processFile } from "./core.js";
|
|
3
3
|
import getUserConfig from "./readConfig.js";
|
|
4
4
|
|
|
5
|
-
async function runInitScan() {
|
|
5
|
+
async function runInitScan(isDry = false) {
|
|
6
6
|
const config = getUserConfig();
|
|
7
7
|
|
|
8
8
|
const patterns = config.includeExtensions.map((ext) => `**/*.${ext}`);
|
|
@@ -11,13 +11,27 @@ async function runInitScan() {
|
|
|
11
11
|
ignore: config.excludeFiles.map((dir) => `${dir}/**`),
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
console.log(
|
|
14
|
+
console.log(
|
|
15
|
+
`š Found ${files.length} files. ${
|
|
16
|
+
isDry ? "Dry scanning..." : "Scanning..."
|
|
17
|
+
}`
|
|
18
|
+
);
|
|
15
19
|
|
|
16
20
|
for (const file of files) {
|
|
17
21
|
try {
|
|
18
|
-
|
|
22
|
+
if (isDry) {
|
|
23
|
+
const updated = await processFile(file, config);
|
|
24
|
+
if (updated) {
|
|
25
|
+
console.log(`[Dry Run] Would update: ${file}`);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
const updated = await processFile(file, config);
|
|
29
|
+
if (updated) {
|
|
30
|
+
console.log(`ā
Updated: ${file}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
} catch (e) {
|
|
20
|
-
console.warn(`ā Error in: ${file}
|
|
34
|
+
console.warn(`ā Error in: ${file}`, e);
|
|
21
35
|
}
|
|
22
36
|
}
|
|
23
37
|
|