Skip to content

Commit 8aefdc5

Browse files
committed
fix(setup): use fileURLToPath for spawned generator scripts — URL.pathname breaks on Windows drive letters
1 parent 67933eb commit 8aefdc5

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

scripts/setup/package-generation.mts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* fleet file-size cap.
55
*/
66

7+
import { fileURLToPath } from 'node:url'
8+
79
import { getDefaultLogger } from '@socketsecurity/lib-stable/logger/default'
810
import { spawn } from '@socketsecurity/lib-stable/process/spawn/child'
911

@@ -23,11 +25,15 @@ export async function generateCliSentryPackage({
2325
logger.log('Generating cli-with-sentry package from template…')
2426
}
2527

26-
const scriptPath = new URL(
27-
'../../packages/package-builder/scripts/generate-cli-sentry-package.mts',
28-
import.meta.url,
28+
// fileURLToPath, not URL.pathname: pathname yields `/D:/...` on Windows,
29+
// which node cannot load as a filesystem path.
30+
const scriptPath = fileURLToPath(
31+
new URL(
32+
'../../packages/package-builder/scripts/generate-cli-sentry-package.mts',
33+
import.meta.url,
34+
),
2935
)
30-
const result = await spawn('node', [scriptPath.pathname], {
36+
const result = await spawn('node', [scriptPath], {
3137
stdio: quiet ? 'pipe' : 'inherit',
3238
})
3339

@@ -52,11 +58,14 @@ export async function generateSocketbinPackages({
5258
logger.log('Generating socketbin packages from template…')
5359
}
5460

55-
const scriptPath = new URL(
56-
'../../packages/package-builder/scripts/generate-socketbin-packages.mts',
57-
import.meta.url,
61+
// fileURLToPath, not URL.pathname — see generateCliSentryPackage above.
62+
const scriptPath = fileURLToPath(
63+
new URL(
64+
'../../packages/package-builder/scripts/generate-socketbin-packages.mts',
65+
import.meta.url,
66+
),
5867
)
59-
const result = await spawn('node', [scriptPath.pathname], {
68+
const result = await spawn('node', [scriptPath], {
6069
stdio: quiet ? 'pipe' : 'inherit',
6170
})
6271

0 commit comments

Comments
 (0)