aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bun.js/api/bun.zig17
-rw-r--r--src/bun.js/bindings/Process.cpp14
2 files changed, 8 insertions, 23 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index d3ef6919a..5580e8840 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -440,7 +440,7 @@ pub fn getAssetPrefix(
_: js.JSStringRef,
_: js.ExceptionRef,
) js.JSValueRef {
- return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toValue(ctx.ptr()).asRef();
+ return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toValueGC(ctx.ptr()).asRef();
}
pub fn getArgv(
@@ -450,19 +450,8 @@ pub fn getArgv(
_: js.JSStringRef,
_: js.ExceptionRef,
) js.JSValueRef {
- if (comptime Environment.isWindows) {
- @compileError("argv not supported on windows");
- }
-
- var argv_list = std.heap.stackFallback(128, getAllocator(ctx));
- var allocator = argv_list.get();
- var argv = allocator.alloc(ZigString, std.os.argv.len) catch unreachable;
- defer if (argv.len > 128) allocator.free(argv);
- for (std.os.argv, 0..) |arg, i| {
- argv[i] = ZigString.init(std.mem.span(arg));
- }
-
- return JSValue.createStringArray(ctx.ptr(), argv.ptr, argv.len, true).asObjectRef();
+ // TODO: cache this
+ return JSC.Node.Process.getArgv(ctx).asObjectRef();
}
pub fn getRoutesDir(
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp
index ad8e5d073..69ee11e60 100644
--- a/src/bun.js/bindings/Process.cpp
+++ b/src/bun.js/bindings/Process.cpp
@@ -825,16 +825,12 @@ JSC_DEFINE_CUSTOM_GETTER(Process_getArgv, (JSC::JSGlobalObject * globalObject, J
if (!thisObject) {
return JSValue::encode(JSC::jsUndefined());
}
- auto clientData = WebCore::clientData(vm);
-
- if (JSC::JSValue argv = thisObject->getIfPropertyExists(
- globalObject, clientData->builtinNames().argvPrivateName())) {
- return JSValue::encode(argv);
- }
JSC::EncodedJSValue argv_ = Bun__Process__getArgv(globalObject);
- thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
- JSC::JSValue::decode(argv_));
+ auto clientData = WebCore::clientData(vm);
+
+ thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(),
+ JSC::JSValue::decode(argv_), 0);
return argv_;
}
@@ -852,7 +848,7 @@ JSC_DEFINE_CUSTOM_SETTER(Process_setArgv,
auto clientData = WebCore::clientData(vm);
- return thisObject->putDirect(vm, clientData->builtinNames().argvPrivateName(),
+ return thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(),
JSC::JSValue::decode(value));
}