MCPcopy Create free account
hub / github.com/bytecodealliance/ComponentizeJS / handleCheckInitOutput

Function handleCheckInitOutput

src/componentize.js:590–618  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

588 * @param {() => string} getStderr - A function that resolves to the stderr output of check init
589 */
590async 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

Callers 1

componentizeFunction · 0.85

Calls 2

getStderrFunction · 0.85
stripLinesPrefixesFunction · 0.85

Tested by

no test coverage detected