diff --git a/scripts/link-in-starter.ts b/scripts/link-in-starter.ts index ed794a88..3c9c84eb 100644 --- a/scripts/link-in-starter.ts +++ b/scripts/link-in-starter.ts @@ -2,8 +2,33 @@ import * as child_process from "child_process"; import * as fs from "fs"; import { join } from "path"; import { startRebuildOnSrcChange } from "./startRebuildOnSrcChange"; +import { crawl } from "../src/bin/tools/crawl"; + +{ + const dirPath = "node_modules"; + + try { + fs.rmSync(dirPath, { recursive: true, force: true }); + } catch { + // NOTE: This is a workaround for windows + // we can't remove locked executables. + + crawl({ + dirPath, + returnedPathsType: "absolute" + }).forEach(filePath => { + try { + fs.rmSync(filePath, { force: true }); + } catch (error) { + if (filePath.endsWith(".exe")) { + return; + } + throw error; + } + }); + } +} -fs.rmSync("node_modules", { recursive: true, force: true }); fs.rmSync("dist", { recursive: true, force: true }); fs.rmSync(".yarn_home", { recursive: true, force: true });