chore(build): fix build error on Windows (#11389)

This commit is contained in:
Hongkun Peng 2024-07-19 16:48:13 +08:00 committed by GitHub
parent fd5c001ec7
commit c7f5c70eba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -60,13 +60,14 @@ export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
*/ */
export async function exec(command, args, options) { export async function exec(command, args, options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const process = spawn(command, args, { const _process = spawn(command, args, {
stdio: [ stdio: [
'ignore', // stdin 'ignore', // stdin
'pipe', // stdout 'pipe', // stdout
'pipe', // stderr 'pipe', // stderr
], ],
...options, ...options,
shell: process.platform === 'win32',
}) })
/** /**
@ -78,19 +79,19 @@ export async function exec(command, args, options) {
*/ */
const stdoutChunks = [] const stdoutChunks = []
process.stderr?.on('data', chunk => { _process.stderr?.on('data', chunk => {
stderrChunks.push(chunk) stderrChunks.push(chunk)
}) })
process.stdout?.on('data', chunk => { _process.stdout?.on('data', chunk => {
stdoutChunks.push(chunk) stdoutChunks.push(chunk)
}) })
process.on('error', error => { _process.on('error', error => {
reject(error) reject(error)
}) })
process.on('exit', code => { _process.on('exit', code => {
const ok = code === 0 const ok = code === 0
const stderr = Buffer.concat(stderrChunks).toString().trim() const stderr = Buffer.concat(stderrChunks).toString().trim()
const stdout = Buffer.concat(stdoutChunks).toString().trim() const stdout = Buffer.concat(stdoutChunks).toString().trim()