mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
Fix process.argv with standalone
This commit is contained in:
@@ -1988,13 +1988,19 @@ pub const Process = struct {
|
||||
var args_list = std.ArrayListUnmanaged(JSC.ZigString){ .items = args, .capacity = args.len };
|
||||
args_list.items.len = 0;
|
||||
|
||||
// get the bun executable
|
||||
// without paying the cost of a syscall to resolve the full path
|
||||
args_list.appendAssumeCapacity(
|
||||
JSC.ZigString.init(
|
||||
std.fs.selfExePathAlloc(allocator) catch "bun",
|
||||
).withEncoding(),
|
||||
);
|
||||
if (vm.standalone_module_graph != null) {
|
||||
// Don't break user's code because they did process.argv.slice(2)
|
||||
// Even if they didn't type "bun", we still want to add it
|
||||
args_list.appendAssumeCapacity(
|
||||
JSC.ZigString.init("bun"),
|
||||
);
|
||||
} else {
|
||||
args_list.appendAssumeCapacity(
|
||||
JSC.ZigString.init(
|
||||
std.fs.selfExePathAlloc(allocator) catch "bun",
|
||||
).withEncoding(),
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.main.len > 0)
|
||||
args_list.appendAssumeCapacity(JSC.ZigString.init(vm.main).withEncoding());
|
||||
|
||||
@@ -1114,6 +1114,13 @@ pub const Command = struct {
|
||||
};
|
||||
|
||||
ctx.args.target = Api.Target.bun;
|
||||
var argv = try bun.default_allocator.alloc(string, std.os.argv.len -| 1);
|
||||
if (std.os.argv.len > 1) {
|
||||
for (argv, std.os.argv[1..]) |*dest, src| {
|
||||
dest.* = bun.span(src);
|
||||
}
|
||||
}
|
||||
ctx.passthrough = argv;
|
||||
|
||||
try @import("./bun_js.zig").Run.bootStandalone(
|
||||
ctx,
|
||||
|
||||
Reference in New Issue
Block a user