aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-25 11:43:54 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-25 11:43:54 -0700
commit5bd94b8f47efab5ca736e6ec76b72e991df1da11 (patch)
tree78cef2ee806bc83094ca312e016ae522dbf52eed /src/bun.js
parentaa5432e162be03dbeddb25c5145169859eaeef32 (diff)
downloadbun-5bd94b8f47efab5ca736e6ec76b72e991df1da11.tar.gz
bun-5bd94b8f47efab5ca736e6ec76b72e991df1da11.tar.zst
bun-5bd94b8f47efab5ca736e6ec76b72e991df1da11.zip
Add `process.mainModule`
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/Process.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp
index 69ee11e60..a369faee2 100644
--- a/src/bun.js/bindings/Process.cpp
+++ b/src/bun.js/bindings/Process.cpp
@@ -10,6 +10,7 @@
#include "ImportMetaObject.h"
#include <sys/stat.h>
#include "ZigConsoleClient.h"
+#include <JavaScriptCore/GetterSetter.h>
#pragma mark - Node.js Process
namespace Zig {
@@ -787,6 +788,17 @@ void Process::finishCreation(JSC::VM& vm)
this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "emitWarning"_s),
1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0);
+
+ JSC::JSFunction* requireDotMainFunction = JSFunction::create(
+ vm,
+ moduleMainCodeGenerator(vm),
+ globalObject->globalScope());
+ // https://nodejs.org/api/process.html#processmainmodule
+ this->putDirect(
+ vm,
+ JSC::Identifier::fromString(vm, "mainModule"_s),
+ JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()),
+ PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);
}
const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr,