Skip to content

Commit 830b1c4

Browse files
committed
Cleanup script removes itself after cleanup
1 parent 2d47243 commit 830b1c4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

scripts/cleanup.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,25 @@ const removeAllReadmeFromApp = async (currentDirectory: string) => {
2020
}
2121
};
2222

23+
const removeTheCleanupFromPackageJsonAndScripts = async () => {
24+
const packageJson = JSON.parse(
25+
await fs.readFile("package.json", { encoding: "utf-8" })
26+
);
27+
28+
delete packageJson.scripts.cleanup;
29+
await fs.writeFile(
30+
"package.json",
31+
JSON.stringify(packageJson, null, 2),
32+
"utf-8"
33+
);
34+
35+
console.log(chalk.green("Cleanup script is removed from package.json"));
36+
await fs.unlink("scripts/cleanup.ts");
37+
};
38+
2339
removeAllReadmeFromApp(appDirectory).then(() => {
2440
console.log(
2541
chalk.green("All README.md files are removed from app directory")
2642
);
2743
});
44+
removeTheCleanupFromPackageJsonAndScripts();

0 commit comments

Comments
 (0)