Merge dd085ee7ed409db1b3056c2b8af6e81c27d75711 into 07247e9b951595317bf66d639ce43d5d313a5c76

This commit is contained in:
Ludea 2024-08-22 10:48:30 +02:00 committed by GitHub
commit 751fca87b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,14 +124,14 @@ async function spawnCmd(
args: string[], args: string[],
options: SpawnOptionsWithoutStdio = {} options: SpawnOptionsWithoutStdio = {}
): Promise<void> { ): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((spawn_resolve, reject) => {
const child = spawn(cmd, args, { const child = spawn(cmd, args, {
...options, ...options,
stdio: ['pipe', 'inherit', 'inherit'], stdio: ['pipe', 'inherit', 'inherit'],
shell: true shell: true
}) })
child.on('exit', () => resolve) child.on('exit', () => spawn_resolve)
child.on('error', error => { child.on('error', error => {
reject(error) reject(error)
@ -150,20 +150,20 @@ async function execCmd(
args: string[], args: string[],
options: Omit<ExecOptionsWithStringEncoding, 'encoding'> = {} options: Omit<ExecOptionsWithStringEncoding, 'encoding'> = {}
): Promise<string> { ): Promise<string> {
return new Promise((resolve, reject) => { return new Promise((exe_resolve, reject) => {
exec( exec(
`${cmd} ${args.join(' ')}`, `${cmd} ${args.join(' ')}`,
{...options, encoding: 'utf-8'}, {...options, encoding: 'utf-8'},
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {
console.error( core.error(
`Failed to execute cmd ${cmd} with args: ${args.join( `Failed to execute cmd ${cmd} with args: ${args.join(
' ' ' '
)}. reason: ${error}` )}. reason: ${error}`
) )
reject(stderr) reject(stderr)
} else { } else {
resolve(stdout) exe_resolve(stdout)
} }
} }
) )