Skip to content

Commit df81c99

Browse files
authored
Make qjs --std switch include bjson module (#640)
1 parent dfe5675 commit df81c99

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

qjs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void help(void)
320320
"-m --module load as ES6 module (default=autodetect)\n"
321321
" --script load as ES6 script (default=autodetect)\n"
322322
"-I --include file include an additional file\n"
323-
" --std make 'std' and 'os' available to the loaded script\n"
323+
" --std make 'std', 'os' and 'bjson' available to script\n"
324324
"-T --trace trace memory allocation\n"
325325
"-d --dump dump the memory usage stats\n"
326326
"-D --dump-flags flags for dumping debug data (see DUMP_* defines)\n"
@@ -522,8 +522,11 @@ int main(int argc, char **argv)
522522

523523
/* make 'std' and 'os' visible to non module code */
524524
if (load_std) {
525-
const char *str = "import * as std from 'std';\n"
526-
"import * as os from 'os';\n"
525+
const char *str =
526+
"import * as bjson from 'qjs:bjson';\n"
527+
"import * as std from 'qjs:std';\n"
528+
"import * as os from 'qjs:os';\n"
529+
"globalThis.bjson = bjson;\n"
527530
"globalThis.std = std;\n"
528531
"globalThis.os = os;\n";
529532
eval_buf(ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE);

0 commit comments

Comments
 (0)