( command: string, options?: SpawnOptionsWithoutStdio )
| 26 | }; |
| 27 | |
| 28 | const spawnAsync = async ( |
| 29 | command: string, |
| 30 | options?: SpawnOptionsWithoutStdio |
| 31 | ) => |
| 32 | new Promise<Buffer>((resolve, reject) => { |
| 33 | const [spawnCommand, ...args] = command.split(/\s+/); |
| 34 | const spawnProcess = spawn(spawnCommand, args, options); |
| 35 | const chunks: Buffer[] = []; |
| 36 | const errorChunks: Buffer[] = []; |
| 37 | spawnProcess.stdout.on('data', (data) => { |
| 38 | process.stdout.write(data.toString()); |
| 39 | chunks.push(data); |
| 40 | }); |
| 41 | spawnProcess.stderr.on('data', (data) => { |
| 42 | process.stderr.write(data.toString()); |
| 43 | errorChunks.push(data); |
| 44 | }); |
| 45 | spawnProcess.on('error', (error) => { |
| 46 | reject(error); |
| 47 | }); |
| 48 | spawnProcess.on('close', (code) => { |
| 49 | if (code === 1) { |
| 50 | reject(Buffer.concat(errorChunks).toString()); |
| 51 | return; |
| 52 | } |
| 53 | resolve(Buffer.concat(chunks)); |
| 54 | }); |
| 55 | }); |
| 56 | |
| 57 | export type DeployBuilderOptions = DeployBuilderSchema & Record<string, any>; |
| 58 |
no test coverage detected