1
1
import fs from 'node:fs'
2
2
import path from 'node:path'
3
3
import { fileURLToPath } from 'node:url'
4
+ import type { SpawnOptions } from 'node:child_process'
4
5
import spawn from 'cross-spawn'
5
6
import mri from 'mri'
6
7
import * as prompts from '@clack/prompts'
@@ -357,14 +358,14 @@ const renameFiles: Record<string, string | undefined> = {
357
358
358
359
const defaultTargetDir = 'vite-project'
359
360
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 )
362
363
if ( status != null && status > 0 ) {
363
364
process . exit ( status )
364
365
}
365
366
366
367
if ( error ) {
367
- console . error ( `\n${ params . slice ( 0 , - 1 ) . join ( ' ' ) } error!` )
368
+ console . error ( `\n${ command } ${ args . join ( ' ' ) } error!` )
368
369
console . error ( error )
369
370
process . exit ( 1 )
370
371
}
@@ -378,7 +379,7 @@ function install(root: string, agent: string) {
378
379
return
379
380
}
380
381
prompts . log . step ( `Installing dependencies with ${ agent } ...` )
381
- run ( agent , getInstallCommand ( agent ) , {
382
+ run ( getInstallCommand ( agent ) , {
382
383
stdio : 'inherit' ,
383
384
cwd : root ,
384
385
} )
@@ -390,7 +391,7 @@ function start(root: string, agent: string) {
390
391
return
391
392
}
392
393
prompts . log . step ( 'Starting dev server...' )
393
- run ( agent , getRunCommand ( agent , 'dev' ) , {
394
+ run ( getRunCommand ( agent , 'dev' ) , {
394
395
stdio : 'inherit' ,
395
396
cwd : root ,
396
397
} )
0 commit comments