-
-
Notifications
You must be signed in to change notification settings - Fork 779
Expand file tree
/
Copy pathrefactor.js
More file actions
24 lines (21 loc) · 891 Bytes
/
refactor.js
File metadata and controls
24 lines (21 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require("fs");
const path = require("path");
function addPublishConfigToPackageJson(directory) {
fs.readdirSync(directory, { withFileTypes: true }).forEach((entry) => {
const fullPath = path.join(directory, entry.name);
if (entry.isDirectory()) {
addPublishConfigToPackageJson(fullPath);
} else if (entry.isFile() && entry.name === "package.json") {
const packageJson = JSON.parse(fs.readFileSync(fullPath, "utf8"));
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.clean = 'rm -rf node_modules .tshy .tshy-build dist .turbo'
fs.writeFileSync(fullPath, JSON.stringify(packageJson, null, 2));
console.log(`Updated publishConfig in: ${fullPath}`);
}
});
}
// Run the script in the current directory
addPublishConfigToPackageJson(".");
console.log("Package.json updates complete.");