Skip to content

Commit cd9b99f

Browse files
refactor: constants
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent 6101726 commit cd9b99f

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/componentize.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { freemem } from "node:os";
1+
import { freemem } from 'node:os';
22
import { TextDecoder } from 'node:util';
33
import { Buffer } from 'node:buffer';
44
import { fileURLToPath } from 'node:url';
@@ -26,11 +26,34 @@ import {
2626
export const { version } = JSON.parse(
2727
await readFile(new URL('../package.json', import.meta.url), 'utf8'),
2828
);
29-
const isWindows = platform === 'win32';
29+
30+
/** Whether the current platform is windows */
31+
const IS_WINDOWS = platform === 'win32';
32+
33+
/** Prefix into wizer error output that indicates a error/trap */
34+
const WIZER_ERROR_CAUSE_PREFIX = `Error: the \`componentize.wizer\` function trapped
35+
Caused by:`;
36+
37+
/** Prefix into wizer error output that indicates exit status */
38+
const WIZER_EXIT_CODE_PREFIX = 'Exited with i32 exit status';
39+
40+
/** Response code from check_init() that denotes success */
41+
const CHECK_INIT_RETURN_OK = 0;
42+
43+
/** Response code from check_init() that denotes being unable to extract exports list */
44+
const CHECK_INIT_RETURN_FN_LIST = 1;
45+
46+
/** Response code from check_init() that denotes being unable to parse core ABI export types */
47+
const CHECK_INIT_RETURN_TYPE_PARSE = 2;
48+
49+
/** Default path to the AOT weval cache */
50+
const DEFAULT_AOT_CACHE = fileURLToPath(
51+
new URL(`../lib/starlingmonkey_ics.wevalcache`, import.meta.url),
52+
);
3053

3154
function maybeWindowsPath(path) {
3255
if (!path) return path;
33-
if (!isWindows) return resolve(path);
56+
if (!IS_WINDOWS) return resolve(path);
3457
return '//?/' + resolve(path).replace(/\\/g, '/');
3558
}
3659

@@ -402,19 +425,15 @@ export async function componentize(
402425
};
403426
}
404427

405-
const INIT_OK = 0;
406-
const INIT_FN_LIST = 1;
407-
const INIT_TYPE_PARSE = 2;
408-
409428
const status = check_init();
410429
let err = null;
411430
switch (status) {
412-
case INIT_OK:
431+
case CHECK_INIT_RETURN_OK:
413432
break;
414-
case INIT_FN_LIST:
433+
case CHECK_INIT_RETURN_FN_LIST:
415434
err = `Unable to extract expected exports list`;
416435
break;
417-
case INIT_TYPE_PARSE:
436+
case CHECK_INIT_RETURN_TYPE_PARSE:
418437
err = `Unable to parse the core ABI export types`;
419438
break;
420439
default:

0 commit comments

Comments
 (0)