Skip to content

Commit 3059be6

Browse files
committed
build(windows): fix pnpm exec quoting on Windows and preserve PATH for pnpm node
Use execa(file,args) for pnpm invocations to avoid cmd quoting issues. Keep PATH so 'pnpm node' subcommand can resolve node. This should fix build-kit on Windows.
1 parent 2cecc6f commit 3059be6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

build/build-kit.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { homedir, platform } from 'node:os'
44
import { existsSync, readFileSync } from 'node:fs'
55
import { rimraf } from 'rimraf'
66
import { chmod as fsChmod, writeFile } from 'node:fs/promises'
7-
import { execaCommand as exec, type Options } from 'execa'
7+
import { execa as execFile, execaCommand as exec, type Options } from 'execa'
88
import { ensureDir, move, pathExists } from 'fs-extra'
99
import { downloadAndInstallPnpm } from './pnpm'
1010

@@ -313,23 +313,23 @@ if (packageJsonChanged) {
313313

314314
const pnpmExec = kitPath(pnpmFile)
315315
console.log(`Checking node path with pnpm node -e at ${pnpmExec}`)
316-
await exec(`"${pnpmExec}" node -e "console.log(process.execPath)"`, {
316+
await execFile(pnpmExec, ['node', '-e', 'console.log(process.execPath)'], {
317317
cwd: kitPath(),
318318
stdio: 'inherit',
319319
env: {
320320
PNPM_HOME: kitPath(),
321-
PATH: ''
321+
PATH: process.env.PATH
322322
}
323323
})
324324
console.log('Node path check completed')
325325

326326
const pnpmPath = kitPath(pnpmFile)
327327
console.log(`Installing production dependencies using ${pnpmPath}...`)
328-
await exec(`"${pnpmPath}" i --prod`, options)
328+
await execFile(pnpmPath, ['i', '--prod'], { cwd: kitPath(), stdio: 'inherit' })
329329
console.log('Production dependencies installed successfully')
330330

331331
console.log('Installing development tools (esbuild, vite, tsx)...')
332-
await exec(`"${pnpmPath}" i esbuild vite tsx`, options)
332+
await execFile(pnpmPath, ['i', 'esbuild', 'vite', 'tsx'], { cwd: kitPath(), stdio: 'inherit' })
333333
console.log('Development tools installed successfully')
334334
} catch (error) {
335335
console.error('Error installing dependencies:', error)
@@ -347,11 +347,11 @@ if (packageJsonChanged) {
347347

348348
const pnpmPath = kitPath(pnpmFile)
349349
console.log(`Installing production dependencies using ${pnpmPath}...`)
350-
await exec(`"${pnpmPath}" i --prod`, options)
350+
await execFile(pnpmPath, ['i', '--prod'], { cwd: kitPath(), stdio: 'inherit' })
351351
console.log('Production dependencies installed successfully')
352352

353353
console.log('Installing development tools (esbuild, vite, tsx)...')
354-
await exec(`"${pnpmPath}" i esbuild vite tsx`, options)
354+
await execFile(pnpmPath, ['i', 'esbuild', 'vite', 'tsx'], { cwd: kitPath(), stdio: 'inherit' })
355355
console.log('Development tools installed successfully')
356356
} catch (error) {
357357
console.error('Error installing dependencies:', error)

0 commit comments

Comments
 (0)