(process: RooTerminalProcess, promise: Promise<void>)
| 4 | // TerminalProcess and a Promise: |
| 5 | // https://github.com/sindresorhus/execa/blob/main/lib/methods/promise.js |
| 6 | export function mergePromise(process: RooTerminalProcess, promise: Promise<void>): RooTerminalProcessResultPromise { |
| 7 | const nativePromisePrototype = (async () => {})().constructor.prototype |
| 8 | |
| 9 | const descriptors = ["then", "catch", "finally"].map( |
| 10 | (property) => [property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)] as const, |
| 11 | ) |
| 12 | |
| 13 | for (const [property, descriptor] of descriptors) { |
| 14 | if (descriptor) { |
| 15 | const value = descriptor.value.bind(promise) |
| 16 | Reflect.defineProperty(process, property, { ...descriptor, value }) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | return process as RooTerminalProcessResultPromise |
| 21 | } |
no outgoing calls
no test coverage detected