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;aACb,CAAC,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,IAAI,WAAW,EAAE;YACf,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;SACxC;aAAM;YACL,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;SACzC;QACD,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACrC,CAAC,CAA8B,CAAC;IAChC,6FAA6F;IAC7F,oCAAoC;IACpC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,OAAO,OAAO,CAAC;AACjB,CAAC;AAnFD,6BAmFC","sourcesContent":["import { ChildProcess, SpawnOptions as NodeSpawnOptions } from 'child_process';\nimport spawn from 'cross-spawn';\n\nexport interface SpawnOptions extends NodeSpawnOptions {\n ignoreStdio?: boolean;\n}\n\nexport interface SpawnPromise<T> extends Promise<T> {\n child: ChildProcess;\n}\n\nexport interface SpawnResult {\n pid: number;\n output: string[];\n stdout: string;\n stderr: string;\n status: number | null;\n signal: string | null;\n}\n\nexport default function spawnAsync(\n command: string,\n args?: ReadonlyArray<string>,\n options: SpawnOptions = {}\n): SpawnPromise<SpawnResult> {\n const fakeErr = new Error('fake error just to preserve stacktrace');\n const previousStack = fakeErr.stack && fakeErr.stack.split('\\n').splice(1);\n const previousStackString = previousStack && [' ...', ...previousStack].join('\\n');\n\n let child: ChildProcess;\n let promise = new Promise((resolve, reject) => {\n let { ignoreStdio, ...nodeOptions } = options;\n // @ts-ignore: cross-spawn declares \"args\" to be a regular array instead of a read-only one\n child = spawn(command, args, nodeOptions);\n let stdout = '';\n let stderr = '';\n\n if (!ignoreStdio) {\n if (child.stdout) {\n child.stdout.on('data', data => {\n stdout += data;\n });\n }\n\n if (child.stderr) {\n child.stderr.on('data', data => {\n stderr += data;\n });\n }\n }\n\n let completionListener = (code: number | null, signal: string | null) => {\n child.removeListener('error', errorListener);\n
|