From 0440d400afa18d4790e385ba92dd83be23e55bb0 Mon Sep 17 00:00:00 2001
From: The Ghost of FOSS' Future
<163201376+sneedgroup-holder@users.noreply.github.com>
Date: Thu, 9 Jan 2025 00:26:20 +0000
Subject: [PATCH] Update qjs.c
---
qjs.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/qjs.c b/qjs.c
index 72ebb81..bd541b5 100644
--- a/qjs.c
+++ b/qjs.c
@@ -621,7 +621,22 @@ start:
/* exit on unhandled promise rejections */
JS_SetHostPromiseRejectionTracker(rt, js_std_promise_rejection_tracker, NULL);
- //POLYFILLS FOR QJS FILES BEGIN
+ if (!empty_run) {
+ js_std_add_helpers(ctx, argc - optind, argv + optind);
+
+ /* make 'std' and 'os' visible to non module code */
+ if (load_std) {
+ const char *str =
+ "import * as bjson from 'qjs:bjson';\n"
+ "import * as std from 'qjs:std';\n"
+ "import * as os from 'qjs:os';\n"
+ "globalThis.bjson = bjson;\n"
+ "globalThis.std = std;\n"
+ "globalThis.os = os;\n";
+ eval_buf(ctx, str, strlen(str), "", JS_EVAL_TYPE_MODULE);
+ }
+
+ //POLYFILLS FOR QJS FILES BEGIN
const char *pf = "globalThis.global = globalThis;\n"
"global.console.error = console.log\n"
"global.console.warn = console.log\n"
@@ -651,21 +666,6 @@ start:
eval_buf(ctx, pf, strlen(pf), "", JS_EVAL_TYPE_MODULE);
- if (!empty_run) {
- js_std_add_helpers(ctx, argc - optind, argv + optind);
-
- /* make 'std' and 'os' visible to non module code */
- if (load_std) {
- const char *str =
- "import * as bjson from 'qjs:bjson';\n"
- "import * as std from 'qjs:std';\n"
- "import * as os from 'qjs:os';\n"
- "globalThis.bjson = bjson;\n"
- "globalThis.std = std;\n"
- "globalThis.os = os;\n";
- eval_buf(ctx, str, strlen(str), "", JS_EVAL_TYPE_MODULE);
- }
-
for(i = 0; i < include_count; i++) {
if (eval_file(ctx, include_list[i], 0))
goto fail;