From 1cbc96847c23e34083c7f535743cb110b8e824de Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 2 Oct 2020 16:02:02 +1000 Subject: [PATCH] Add script to dump globals provided by a JS engine --- dump-env.mjs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 dump-env.mjs diff --git a/dump-env.mjs b/dump-env.mjs new file mode 100755 index 0000000..11d89f3 --- /dev/null +++ b/dump-env.mjs @@ -0,0 +1,19 @@ +#!/bin/sh +//bin/sh -c :; exec node "$0" -- "$@"; # -*- JS -*- + +import print from "./print.mjs"; + +const str = print(globalThis, "globalThis", { + all: true, + colours: true, + proto: true, + maxDepth: Infinity, +}); + +if("object" === typeof console && console && "function" === typeof console.log) + console.log(str); + +else if("function" === typeof globalThis.print && globalThis.print !== print) + globalThis.print(str); + +else throw str;