diff options
Diffstat (limited to '')
-rw-r--r-- | src/bun.js/node/types.zig | 20 | ||||
-rw-r--r-- | src/cli.zig | 7 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index dacb9540c..97098391e 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -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()); diff --git a/src/cli.zig b/src/cli.zig index 621f54fd2..3b1f7e305 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -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, |