1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const fs = require("fs");
|
7 | const path = require("path");
|
8 | const sortJson = require("sort-json");
|
9 |
|
10 | (async () => {
|
11 | const args = process.argv.slice(2);
|
12 | const sourcePath = args[0];
|
13 | const files = await fs.promises.readdir(sourcePath);
|
14 |
|
15 | for (const file of files) {
|
16 | const filePath = path.join(sourcePath, file);
|
17 | const content = fs.readFileSync(filePath);
|
18 | const json = JSON.parse(content);
|
19 |
|
20 |
|
21 | delete json.parser;
|
22 |
|
23 |
|
24 | fs.writeFileSync(filePath, JSON.stringify(json, undefined, 4));
|
25 |
|
26 |
|
27 | sortJson.overwrite(filePath, { indentSize: 4 });
|
28 | }
|
29 | })();
|