Skip to content

Commit 01ae663

Browse files
fix(create-vite): fix installing dependencies (#20826)
1 parent 0021527 commit 01ae663

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/create-vite/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
33
import { fileURLToPath } from 'node:url'
4+
import type { SpawnOptions } from 'node:child_process'
45
import spawn from 'cross-spawn'
56
import mri from 'mri'
67
import * as prompts from '@clack/prompts'
@@ -357,14 +358,14 @@ const renameFiles: Record<string, string | undefined> = {
357358

358359
const defaultTargetDir = 'vite-project'
359360

360-
function run(...params: Parameters<typeof spawn.sync>) {
361-
const { status, error } = spawn.sync(...params)
361+
function run([command, ...args]: string[], options?: SpawnOptions) {
362+
const { status, error } = spawn.sync(command, args, options)
362363
if (status != null && status > 0) {
363364
process.exit(status)
364365
}
365366

366367
if (error) {
367-
console.error(`\n${params.slice(0, -1).join(' ')} error!`)
368+
console.error(`\n${command} ${args.join(' ')} error!`)
368369
console.error(error)
369370
process.exit(1)
370371
}
@@ -378,7 +379,7 @@ function install(root: string, agent: string) {
378379
return
379380
}
380381
prompts.log.step(`Installing dependencies with ${agent}...`)
381-
run(agent, getInstallCommand(agent), {
382+
run(getInstallCommand(agent), {
382383
stdio: 'inherit',
383384
cwd: root,
384385
})
@@ -390,7 +391,7 @@ function start(root: string, agent: string) {
390391
return
391392
}
392393
prompts.log.step('Starting dev server...')
393-
run(agent, getRunCommand(agent, 'dev'), {
394+
run(getRunCommand(agent, 'dev'), {
394395
stdio: 'inherit',
395396
cwd: root,
396397
})

0 commit comments

Comments
 (0)