Skip to content

Commit fd2a90d

Browse files
committed
use exec to delete folders
1 parent cd9a661 commit fd2a90d

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

packages/open-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"access": "public"
44
},
55
"name": "open-next",
6-
"version": "0.0.0-bloat.3",
6+
"version": "0.0.0-bloat.4",
77
"bin": {
88
"open-next": "./dist/index.js"
99
},

packages/open-next/src/build.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createRequire as topLevelCreateRequire } from "node:module";
44
import path from "node:path";
55
import url from "node:url";
66

7+
import { exec } from "child_process";
78
import {
89
build as buildAsync,
910
BuildOptions as ESBuildOptions,
@@ -709,7 +710,7 @@ async function createServerBundle(monorepoRoot: string, streaming = false) {
709710
addCacheHandler(outputPath, options.dangerous);
710711

711712
removeNodeModule(path.join(outputPath, "node_modules"), [
712-
"@esbuild",
713+
"@esbuild*",
713714
"@prisma/engines/download",
714715
"@prisma/internals/dist/libquery_engine*",
715716
"@prisma/internals/dist/get-generators/libquery_engine*",
@@ -1026,11 +1027,23 @@ function compareSemver(v1: string, v2: string): number {
10261027
}
10271028

10281029
function removeNodeModule(nodeModulesPath: string, modules: string[]) {
1029-
console.log("removing: ", modules);
1030+
console.log("Removing: ", modules);
1031+
const isWindows = process.platform === "win32";
1032+
10301033
for (const module of modules) {
1031-
fs.rmSync(path.join(nodeModulesPath, module), {
1032-
force: true,
1033-
recursive: true,
1034-
});
1034+
const modulePath = path.join(nodeModulesPath, module);
1035+
const pnpmModulePath = path.join(nodeModulesPath, ".pnpm", module);
1036+
1037+
if (isWindows) {
1038+
exec(
1039+
`PowerShell -Command "Remove-Item -Path '${modulePath}' -Recurse -Force"`,
1040+
);
1041+
exec(
1042+
`PowerShell -Command "Remove-Item -Path '${pnpmModulePath}' -Recurse -Force"`,
1043+
);
1044+
} else {
1045+
exec(`rm -rf ${modulePath}`);
1046+
exec(`rm -rf ${pnpmModulePath}`);
1047+
}
10351048
}
10361049
}

0 commit comments

Comments
 (0)