* Handle the output of `check_init()` * * @param {number} status - output of check_init * @param {string} initializerPath * @param {string} workDir * @param {() => string} getStderr - A function that resolves to the stderr output of check init
( status, initializerPath, workDir, getStderr, )
| 588 | * @param {() => string} getStderr - A function that resolves to the stderr output of check init |
| 589 | */ |
| 590 | async function handleCheckInitOutput( |
| 591 | status, |
| 592 | initializerPath, |
| 593 | workDir, |
| 594 | getStderr, |
| 595 | ) { |
| 596 | let err = null; |
| 597 | switch (status) { |
| 598 | case CHECK_INIT_RETURN_OK: |
| 599 | break; |
| 600 | case CHECK_INIT_RETURN_FN_LIST: |
| 601 | err = `Unable to extract expected exports list`; |
| 602 | break; |
| 603 | case CHECK_INIT_RETURN_TYPE_PARSE: |
| 604 | err = `Unable to parse the core ABI export types`; |
| 605 | break; |
| 606 | default: |
| 607 | err = `Unknown error during initialization: ${status}`; |
| 608 | } |
| 609 | |
| 610 | if (err) { |
| 611 | let msg = err; |
| 612 | const stderr = getStderr(); |
| 613 | if (stderr) { |
| 614 | msg += `\n${stripLinesPrefixes(stderr, [new RegExp(`${initializerPath}[:\\d]* ?`)], workDir)}`; |
| 615 | } |
| 616 | throw new Error(msg); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Detect known exports that correspond to certain interfaces |
no test coverage detected