child_process#SpawnSyncOptions TypeScript Examples
The following examples show how to use
child_process#SpawnSyncOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: lib.ts From xcodebuild with The Unlicense | 6 votes |
export function spawn(
arg0: string,
args: string[],
options: SpawnSyncOptions = { stdio: 'inherit' }
): void {
const { error, signal, status } = spawnSync(arg0, args, options)
if (error) throw error
if (signal) throw new Error(`\`${arg0}\` terminated with signal (${signal})`)
if (status != 0) throw new Error(`\`${arg0}\` aborted (${status})`)
}
Example #2
Source File: spawn.ts From gitmars with GNU General Public License v3.0 | 6 votes |
/**
* 同步执行脚本
*
* @param client - 执行脚本的宿主,名称
* @param argv - 参数
* @param options - 透传配置
* @returns result - 返回执行状态
*/
export function spawnSync(
client: string,
argv: string[],
options: SpawnSyncOptions = {}
): Partial<SpawnSyncReturns<string>> {
let len = argv.length
while (len--) {
!argv[len] && argv.splice(len, 1)
}
const program = crossSpawn.sync(client, argv, {
// stdio: 'inherit',
shell: process.platform === 'win32',
...options
})
debug(client, argv)
return {
pid: program.pid,
stdout: program.stdout
? program.stdout.toString().replace(/\s+$/, '')
: '',
stderr: program.stderr ? program.stderr.toString() : '',
status: program.status,
signal: program.signal,
error: program.error
}
}