-
-
Notifications
You must be signed in to change notification settings - Fork 779
Expand file tree
/
Copy pathrefactor.js
More file actions
23 lines (20 loc) · 765 Bytes
/
refactor.js
File metadata and controls
23 lines (20 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 === ".eslintrc.mjs") {
fs.unlinkSync(fullPath);
const dir = path.dirname(fullPath);
fs.writeFileSync(
path.join(dir, "eslint.config.mjs"),
`import shared from "@jimp/config-eslint/base.js";\nexport default [...shared];`
);
}
});
}
// Run the script in the current directory
addPublishConfigToPackageJson(".");
console.log("Package.json updates complete.");