From fd41247d372d5cac41b86aaf1260df15e4cf08f5 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Fri, 24 Jan 2025 08:00:17 -0500 Subject: [PATCH] fix: ensure safe removal of node_modules directory in build process --- apps/create-kunkun/build.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/create-kunkun/build.ts b/apps/create-kunkun/build.ts index 370246a..13027d6 100644 --- a/apps/create-kunkun/build.ts +++ b/apps/create-kunkun/build.ts @@ -55,7 +55,10 @@ for (const p of fs.readdirSync(tmpDistTemplatesPath)) { // Replace local template with remote schema patchManifestJsonSchema(pkgJsonPath) // remove node_modules - fs.rmdirSync(path.join(distPath, "templates", p, "node_modules"), { recursive: true }) + const nodeModulesPath = path.join(distPath, "templates", p, "node_modules") + if (fs.existsSync(nodeModulesPath)) { + fs.rmdirSync(nodeModulesPath, { recursive: true }) + } } }