diff --git a/src/bun_js.zig b/src/bun_js.zig index 73ce474679bb58..f23b8dfcdda660 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -42,8 +42,7 @@ pub const Run = struct { arena: Arena, any_unhandled: bool = false, - pub fn bootStandalone(ctx_: Command.Context, entry_path: string, graph: bun.StandaloneModuleGraph) !void { - var ctx = ctx_; + pub fn bootStandalone(ctx: Command.Context, entry_path: string, graph: bun.StandaloneModuleGraph) !void { JSC.markBinding(@src()); bun.JSC.initialize(); @@ -55,7 +54,7 @@ pub const Run = struct { var arena = try Arena.init(); if (!ctx.debug.loaded_bunfig) { - try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand); + try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand); } run = .{ @@ -123,7 +122,7 @@ pub const Run = struct { vm.global.vm().holdAPILock(&run, callback); } - fn bootBunShell(ctx: *const Command.Context, entry_path: []const u8) !bun.shell.ExitCode { + fn bootBunShell(ctx: Command.Context, entry_path: []const u8) !bun.shell.ExitCode { @setCold(true); // this is a hack: make dummy bundler so we can use its `.runEnvLoader()` function to populate environment variables probably should split out the functionality @@ -139,16 +138,15 @@ pub const Run = struct { return bun.shell.Interpreter.initAndRunFromFile(ctx, mini, entry_path); } - pub fn boot(ctx_: Command.Context, entry_path: string) !void { - var ctx = ctx_; + pub fn boot(ctx: Command.Context, entry_path: string) !void { JSC.markBinding(@src()); if (!ctx.debug.loaded_bunfig) { - try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand); + try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand); } if (strings.endsWithComptime(entry_path, ".sh")) { - const exit_code = try bootBunShell(&ctx, entry_path); + const exit_code = try bootBunShell(ctx, entry_path); Global.exitWide(exit_code); return; } diff --git a/src/bunfig.zig b/src/bunfig.zig index 755b33eef09c25..c38b202ea87bb6 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -49,7 +49,7 @@ pub const Bunfig = struct { log: *logger.Log, allocator: std.mem.Allocator, bunfig: *Api.TransformOptions, - ctx: *Command.Context, + ctx: Command.Context, fn addError(this: *Parser, loc: logger.Loc, comptime text: string) !void { this.log.addError(this.source, loc, text) catch unreachable; @@ -777,7 +777,7 @@ pub const Bunfig = struct { } }; - pub fn parse(allocator: std.mem.Allocator, source: logger.Source, ctx: *Command.Context, comptime cmd: Command.Tag) !void { + pub fn parse(allocator: std.mem.Allocator, source: logger.Source, ctx: Command.Context, comptime cmd: Command.Tag) !void { const log_count = ctx.log.errors + ctx.log.warnings; const expr = if (strings.eqlComptime(source.path.name.ext[1..], "toml")) TOML.parse(&source, ctx.log, allocator) catch |err| { diff --git a/src/cli.zig b/src/cli.zig index ecb553e624864c..ef4986a9119332 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -261,7 +261,7 @@ pub const Arguments = struct { Global.exit(0); } - pub fn loadConfigPath(allocator: std.mem.Allocator, auto_loaded: bool, config_path: [:0]const u8, ctx: *Command.Context, comptime cmd: Command.Tag) !void { + pub fn loadConfigPath(allocator: std.mem.Allocator, auto_loaded: bool, config_path: [:0]const u8, ctx: Command.Context, comptime cmd: Command.Tag) !void { var config_file = switch (bun.sys.openA(config_path, std.os.O.RDONLY, 0)) { .result => |fd| fd.asFile(), .err => |err| { @@ -306,7 +306,7 @@ pub const Arguments = struct { return null; } - pub fn loadConfig(allocator: std.mem.Allocator, user_config_path_: ?string, ctx: *Command.Context, comptime cmd: Command.Tag) !void { + pub fn loadConfig(allocator: std.mem.Allocator, user_config_path_: ?string, ctx: Command.Context, comptime cmd: Command.Tag) !void { var config_buf: [bun.MAX_PATH_BYTES]u8 = undefined; if (comptime cmd.readGlobalConfig()) { if (!ctx.has_loaded_global_config) { @@ -368,12 +368,12 @@ pub const Arguments = struct { comptime cmd: Command.Tag, allocator: std.mem.Allocator, args: clap.Args(clap.Help, cmd.params()), - ctx: *Command.Context, + ctx: Command.Context, ) !void { return try loadConfig(allocator, args.option("--config"), ctx, comptime cmd); } - pub fn parse(allocator: std.mem.Allocator, ctx: *Command.Context, comptime cmd: Command.Tag) !Api.TransformOptions { + pub fn parse(allocator: std.mem.Allocator, ctx: Command.Context, comptime cmd: Command.Tag) !Api.TransformOptions { var diag = clap.Diagnostic{}; const params_to_parse = comptime cmd.params(); @@ -1136,7 +1136,18 @@ pub const Command = struct { } = .{}, }; - pub const Context = struct { + var global_cli_ctx: Context = undefined; + + var context_data: ContextData = ContextData{ + .args = std.mem.zeroes(Api.TransformOptions), + .log = undefined, + .start_time = 0, + .allocator = undefined, + }; + + pub const init = ContextData.create; + + pub const ContextData = struct { start_time: i128, args: Api.TransformOptions, log: *logger.Log, @@ -1173,34 +1184,28 @@ pub const Command = struct { minify_identifiers: bool = false, }; - const _ctx = Command.Context{ - .args = std.mem.zeroes(Api.TransformOptions), - .log = undefined, - .start_time = 0, - .allocator = undefined, - }; - pub fn create(allocator: std.mem.Allocator, log: *logger.Log, comptime command: Command.Tag) anyerror!Context { Cli.cmd = command; - var ctx = _ctx; - ctx.log = log; - ctx.start_time = start_time; - ctx.allocator = allocator; + global_cli_ctx = &context_data; + global_cli_ctx.log = log; + global_cli_ctx.start_time = start_time; + global_cli_ctx.allocator = allocator; if (comptime Command.Tag.uses_global_options.get(command)) { - ctx.args = try Arguments.parse(allocator, &ctx, command); + global_cli_ctx.args = try Arguments.parse(allocator, global_cli_ctx, command); } if (comptime Environment.isWindows) { - if (ctx.debug.hot_reload == .watch and !bun.isWatcherChild()) { + if (global_cli_ctx.debug.hot_reload == .watch and !bun.isWatcherChild()) { // this is noreturn bun.becomeWatcherManager(allocator); } } - return ctx; + return global_cli_ctx; } }; + pub const Context = *ContextData; // std.process.args allocates! const ArgsIterator = struct { @@ -1371,12 +1376,14 @@ pub const Command = struct { // bun build --compile entry point if (try bun.StandaloneModuleGraph.fromExecutable(bun.default_allocator)) |graph| { - var ctx = Command.Context{ + context_data = .{ .args = std.mem.zeroes(Api.TransformOptions), .log = log, .start_time = start_time, .allocator = bun.default_allocator, }; + global_cli_ctx = &context_data; + var ctx = global_cli_ctx; ctx.args.target = Api.Target.bun; if (bun.argv().len > 1) { @@ -1404,7 +1411,7 @@ pub const Command = struct { .InitCommand => return try InitCommand.exec(allocator, bun.argv()), .BuildCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .BuildCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .BuildCommand); + const ctx = try Command.init(allocator, log, .BuildCommand); try BuildCommand.exec(ctx); }, .InstallCompletionsCommand => { @@ -1414,28 +1421,28 @@ pub const Command = struct { }, .InstallCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .InstallCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .InstallCommand); + const ctx = try Command.init(allocator, log, .InstallCommand); try InstallCommand.exec(ctx); return; }, .AddCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .AddCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .AddCommand); + const ctx = try Command.init(allocator, log, .AddCommand); try AddCommand.exec(ctx); return; }, .UpdateCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .UpdateCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .UpdateCommand); + const ctx = try Command.init(allocator, log, .UpdateCommand); try UpdateCommand.exec(ctx); return; }, .BunxCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .BunxCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .BunxCommand); + const ctx = try Command.init(allocator, log, .BunxCommand); try BunxCommand.exec(ctx, bun.argv()[if (is_bunx_exe) 0 else 1..]); return; @@ -1443,7 +1450,7 @@ pub const Command = struct { .ReplCommand => { // TODO: Put this in native code. if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .BunxCommand) unreachable; - var ctx = try Command.Context.create(allocator, log, .BunxCommand); + var ctx = try Command.init(allocator, log, .BunxCommand); ctx.debug.run_in_bun = true; // force the same version of bun used. fixes bun-debug for example var args = bun.argv()[0..]; args[1] = "bun-repl"; @@ -1452,42 +1459,42 @@ pub const Command = struct { }, .RemoveCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RemoveCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .RemoveCommand); + const ctx = try Command.init(allocator, log, .RemoveCommand); try RemoveCommand.exec(ctx); return; }, .LinkCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .LinkCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .LinkCommand); + const ctx = try Command.init(allocator, log, .LinkCommand); try LinkCommand.exec(ctx); return; }, .UnlinkCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .UnlinkCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .UnlinkCommand); + const ctx = try Command.init(allocator, log, .UnlinkCommand); try UnlinkCommand.exec(ctx); return; }, .PackageManagerCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .PackageManagerCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .PackageManagerCommand); + const ctx = try Command.init(allocator, log, .PackageManagerCommand); try PackageManagerCommand.exec(ctx); return; }, .TestCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .TestCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .TestCommand); + const ctx = try Command.init(allocator, log, .TestCommand); try TestCommand.exec(ctx); return; }, .GetCompletionsCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .GetCompletionsCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .GetCompletionsCommand); + const ctx = try Command.init(allocator, log, .GetCompletionsCommand); var filter = ctx.positionals; for (filter, 0..) |item, i| { @@ -1583,7 +1590,7 @@ pub const Command = struct { }); // Create command wraps bunx - const ctx = try Command.Context.create(allocator, log, .CreateCommand); + const ctx = try Command.init(allocator, log, .CreateCommand); var args = try std.process.argsAlloc(allocator); @@ -1699,7 +1706,7 @@ pub const Command = struct { }, .RunCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RunCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .RunCommand); + const ctx = try Command.init(allocator, log, .RunCommand); if (ctx.filters.len > 0) { FilterRun.runScriptsWithFilter(ctx) catch |err| { @@ -1718,20 +1725,20 @@ pub const Command = struct { }, .RunAsNodeCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RunAsNodeCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .RunAsNodeCommand); + const ctx = try Command.init(allocator, log, .RunAsNodeCommand); bun.assert(pretend_to_be_node); try RunCommand.execAsIfNode(ctx); }, .UpgradeCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .UpgradeCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .UpgradeCommand); + const ctx = try Command.init(allocator, log, .UpgradeCommand); try UpgradeCommand.exec(ctx); return; }, .AutoCommand => { if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .AutoCommand) unreachable; - var ctx = Command.Context.create(allocator, log, .AutoCommand) catch |e| { + const ctx = Command.init(allocator, log, .AutoCommand) catch |e| { switch (e) { error.MissingEntryPoint => { HelpCommand.execWithReason(allocator, .explicit); @@ -1805,7 +1812,7 @@ pub const Command = struct { } if (!ctx.debug.loaded_bunfig) { - try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand); + try bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand); } if (ctx.preloads.len > 0) @@ -1820,7 +1827,7 @@ pub const Command = struct { if (default_loader) |loader| { if (loader.canBeRunByBun()) { was_js_like = true; - if (maybeOpenWithBunJS(&ctx)) { + if (maybeOpenWithBunJS(ctx)) { return; } did_check = true; @@ -1828,7 +1835,7 @@ pub const Command = struct { } if (force_using_bun and !did_check) { - if (maybeOpenWithBunJS(&ctx)) { + if (maybeOpenWithBunJS(ctx)) { return; } } @@ -1873,16 +1880,16 @@ pub const Command = struct { try HelpCommand.exec(allocator); }, .ExecCommand => { - var ctx = try Command.Context.create(allocator, log, .RunCommand); + const ctx = try Command.init(allocator, log, .RunCommand); if (ctx.positionals.len > 1) { - try ExecCommand.exec(&ctx); + try ExecCommand.exec(ctx); } else Tag.printHelp(.ExecCommand, true); }, } } - fn maybeOpenWithBunJS(ctx: *Command.Context) bool { + fn maybeOpenWithBunJS(ctx: Command.Context) bool { if (ctx.args.entry_points.len == 0) return false; @@ -1959,7 +1966,7 @@ pub const Command = struct { } BunJS.Run.boot( - ctx.*, + ctx, absolute_script_path.?, ) catch |err| { if (Output.enable_ansi_colors) { diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index 751f8df13f1657..d1c058b1a5e87e 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -36,10 +36,9 @@ var estimated_input_lines_of_code_: usize = undefined; pub const BuildCommand = struct { pub fn exec( - ctx_: Command.Context, + ctx: Command.Context, ) !void { Global.configureAllocator(.{ .long_running = true }); - var ctx = ctx_; const allocator = ctx.allocator; var log = ctx.log; estimated_input_lines_of_code_ = 0; @@ -63,8 +62,8 @@ pub const BuildCommand = struct { } var outfile = ctx.bundler_options.outfile; - this_bundler.options.public_path = ctx_.bundler_options.public_path; - this_bundler.resolver.opts.public_path = ctx_.bundler_options.public_path; + this_bundler.options.public_path = ctx.bundler_options.public_path; + this_bundler.resolver.opts.public_path = ctx.bundler_options.public_path; this_bundler.options.entry_naming = ctx.bundler_options.entry_naming; this_bundler.options.chunk_naming = ctx.bundler_options.chunk_naming; diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig index 01c3f5b4165f9c..79d5de7c42c420 100644 --- a/src/cli/bunx_command.zig +++ b/src/cli/bunx_command.zig @@ -212,8 +212,7 @@ pub const BunxCommand = struct { Global.exit(1); } - pub fn exec(ctx_: bun.CLI.Command.Context, argv: [][:0]const u8) !void { - var ctx = ctx_; + pub fn exec(ctx: bun.CLI.Command.Context, argv: [][:0]const u8) !void { // Don't log stuff ctx.debug.silent = true; diff --git a/src/cli/exec_command.zig b/src/cli/exec_command.zig index 2ed2a11148d237..d15e254873b6ea 100644 --- a/src/cli/exec_command.zig +++ b/src/cli/exec_command.zig @@ -13,7 +13,7 @@ const open = @import("../open.zig"); const Command = bun.CLI.Command; pub const ExecCommand = struct { - pub fn exec(ctx: *Command.Context) !void { + pub fn exec(ctx: Command.Context) !void { const script = ctx.positionals[1]; // this is a hack: make dummy bundler so we can use its `.runEnvLoader()` function to populate environment variables probably should split out the functionality var bundle = try bun.Bundler.init( diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig index 3cbe12fe445c34..68848bf83371e6 100644 --- a/src/cli/package_manager_command.zig +++ b/src/cli/package_manager_command.zig @@ -137,7 +137,7 @@ pub const PackageManagerCommand = struct { const subcommand = getSubcommand(&pm.options.positionals); if (pm.options.global) { - try pm.setupGlobalDir(&ctx); + try pm.setupGlobalDir(ctx); } if (strings.eqlComptime(subcommand, "bin")) { diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 2c3a8d854b284a..9adb0ccd28c8d5 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -266,7 +266,7 @@ pub const RunCommand = struct { const log = Output.scoped(.RUN, false); fn runPackageScriptForeground( - ctx: *Command.Context, + ctx: Command.Context, allocator: std.mem.Allocator, original_script: string, name: string, @@ -1294,12 +1294,11 @@ pub const RunCommand = struct { } pub fn exec( - ctx_: Command.Context, + ctx: Command.Context, comptime bin_dirs_only: bool, comptime log_errors: bool, comptime did_try_open_with_bun_js: bool, ) !bool { - var ctx = ctx_; // Step 1. Figure out what we're trying to run var positionals = ctx.positionals; if (positionals.len > 0 and strings.eqlComptime(positionals[0], "run") or strings.eqlComptime(positionals[0], "r")) { @@ -1384,7 +1383,7 @@ pub const RunCommand = struct { // once we know it's a file, check if they have any preloads if (ext.len > 0 and !has_loader) { if (!ctx.debug.loaded_bunfig) { - try CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", &ctx, .RunCommand); + try CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand); } if (ctx.preloads.len == 0) @@ -1464,7 +1463,7 @@ pub const RunCommand = struct { if (scripts.get(temp_script_buffer[1..])) |prescript| { if (!try runPackageScriptForeground( - &ctx, + ctx, ctx.allocator, prescript, temp_script_buffer[1..], @@ -1479,7 +1478,7 @@ pub const RunCommand = struct { } if (!try runPackageScriptForeground( - &ctx, + ctx, ctx.allocator, script_content, script_name_to_search, @@ -1494,7 +1493,7 @@ pub const RunCommand = struct { if (scripts.get(temp_script_buffer)) |postscript| { if (!try runPackageScriptForeground( - &ctx, + ctx, ctx.allocator, postscript, temp_script_buffer, @@ -1682,10 +1681,9 @@ pub const BunXFastPath = struct { var environment_buffer: bun.WPathBuffer = undefined; /// If this returns, it implies the fast path cannot be taken - fn tryLaunch(ctx_const: Command.Context, path_to_use: [:0]u16, env: *DotEnv.Loader, passthrough: []const []const u8) void { + fn tryLaunch(ctx: Command.Context, path_to_use: [:0]u16, env: *DotEnv.Loader, passthrough: []const []const u8) void { if (!bun.FeatureFlags.windows_bunx_fast_path) return; - var ctx = ctx_const; bun.assert(bun.isSliceInBufferT(u16, path_to_use, &BunXFastPath.direct_launch_buffer)); var command_line = BunXFastPath.direct_launch_buffer[path_to_use.len..]; @@ -1718,7 +1716,7 @@ pub const BunXFastPath = struct { .arguments = command_line[0..i], .force_use_bun = ctx.debug.run_in_bun, .direct_launch_with_bun_js = &directLaunchCallback, - .cli_context = &ctx, + .cli_context = ctx, .environment = env.map.writeWindowsEnvBlock(&environment_buffer) catch return, }; @@ -1734,12 +1732,12 @@ pub const BunXFastPath = struct { debug("did not start via shim", .{}); } - fn directLaunchCallback(wpath: []u16, ctx: *const Command.Context) void { + fn directLaunchCallback(wpath: []u16, ctx: Command.Context) void { const utf8 = bun.strings.convertUTF16toUTF8InBuffer( bun.reinterpretSlice(u8, &direct_launch_buffer), wpath, ) catch return; - Run.boot(ctx.*, utf8) catch |err| { + Run.boot(ctx, utf8) catch |err| { ctx.log.printForLogLevel(Output.errorWriter()) catch {}; Output.err(err, "Failed to run bin \"{s}\"", .{std.fs.path.basename(utf8)}); Global.exit(1); diff --git a/src/install/install.zig b/src/install/install.zig index aec380fac5d1eb..f135cfd57a4bd6 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -6973,13 +6973,11 @@ pub const PackageManager = struct { pub fn init(ctx: Command.Context, comptime subcommand: Subcommand) !*PackageManager { const cli = try CommandLineArguments.parse(ctx.allocator, subcommand); - - var _ctx = ctx; - return initWithCLI(&_ctx, cli, subcommand); + return initWithCLI(ctx, cli, subcommand); } fn initWithCLI( - ctx: *Command.Context, + ctx: Command.Context, cli: CommandLineArguments, comptime subcommand: Subcommand, ) !*PackageManager { @@ -7497,7 +7495,7 @@ pub const PackageManager = struct { } manager.global_dir = try Options.openGlobalDir(explicit_global_dir); - try manager.setupGlobalDir(&ctx); + try manager.setupGlobalDir(ctx); break :brk manager.global_dir.?.makeOpenPath("node_modules", .{}) catch |err| { if (manager.options.log_level != .silent) @@ -7686,7 +7684,7 @@ pub const PackageManager = struct { } manager.global_dir = try Options.openGlobalDir(explicit_global_dir); - try manager.setupGlobalDir(&ctx); + try manager.setupGlobalDir(ctx); break :brk manager.global_dir.?.makeOpenPath("node_modules", .{}) catch |err| { if (manager.options.log_level != .silent) @@ -10082,7 +10080,7 @@ pub const PackageManager = struct { return manager.pending_tasks.load(.Monotonic); } - pub fn setupGlobalDir(manager: *PackageManager, ctx: *const Command.Context) !void { + pub fn setupGlobalDir(manager: *PackageManager, ctx: Command.Context) !void { manager.options.global_bin_dir = try Options.openGlobalBinDir(ctx.install); var out_buffer: [bun.MAX_PATH_BYTES]u8 = undefined; const result = try bun.getFdPath(manager.options.global_bin_dir.fd, &out_buffer); @@ -10607,7 +10605,7 @@ pub const PackageManager = struct { } if (manager.options.global) { - try manager.setupGlobalDir(&ctx); + try manager.setupGlobalDir(ctx); } const packages_len_before_install = manager.lockfile.packages.len; diff --git a/src/install/windows-shim/bun_shim_impl.zig b/src/install/windows-shim/bun_shim_impl.zig index bfa434533aa7ea..92950482acfbcd 100644 --- a/src/install/windows-shim/bun_shim_impl.zig +++ b/src/install/windows-shim/bun_shim_impl.zig @@ -909,9 +909,9 @@ pub const FromBunRunContext = struct { /// Was --bun passed? force_use_bun: bool, /// A pointer to a function that can launch `Run.boot` - direct_launch_with_bun_js: *const fn (wpath: []u16, args: *const CommandContext) void, + direct_launch_with_bun_js: *const fn (wpath: []u16, args: CommandContext) void, /// Command.Context - cli_context: *const CommandContext, + cli_context: CommandContext, /// Passed directly to CreateProcessW's lpEnvironment with CREATE_UNICODE_ENVIRONMENT environment: ?[*]const u16, }; diff --git a/src/shell/interpreter.zig b/src/shell/interpreter.zig index 9e482f1751c06b..85185028184bc3 100644 --- a/src/shell/interpreter.zig +++ b/src/shell/interpreter.zig @@ -605,7 +605,7 @@ pub const EnvMap = struct { /// This interpreter works by basically turning the AST into a state machine so /// that execution can be suspended and resumed to support async. pub const Interpreter = struct { - command_ctx: *const bun.CLI.Command.Context, + command_ctx: bun.CLI.Command.Context, event_loop: JSC.EventLoopHandle, /// This is the arena used to allocate the input shell script's AST nodes, /// tokens, and a string pool used to store all strings. @@ -1082,7 +1082,7 @@ pub const Interpreter = struct { /// If all initialization allocations succeed, the arena will be copied /// into the interpreter struct, so it is not a stale reference and safe to call `arena.deinit()` on error. pub fn init( - ctx: *const bun.CLI.Command.Context, + ctx: bun.CLI.Command.Context, event_loop: JSC.EventLoopHandle, allocator: Allocator, arena: *bun.ArenaAllocator, @@ -1183,7 +1183,7 @@ pub const Interpreter = struct { return .{ .result = interpreter }; } - pub fn initAndRunFromFile(ctx: *const bun.CLI.Command.Context, mini: *JSC.MiniEventLoop, path: []const u8) !bun.shell.ExitCode { + pub fn initAndRunFromFile(ctx: bun.CLI.Command.Context, mini: *JSC.MiniEventLoop, path: []const u8) !bun.shell.ExitCode { var arena = bun.ArenaAllocator.init(bun.default_allocator); const src = src: { var file = try std.fs.cwd().openFile(path, .{}); @@ -1257,7 +1257,7 @@ pub const Interpreter = struct { return code; } - pub fn initAndRunFromSource(ctx: *bun.CLI.Command.Context, mini: *JSC.MiniEventLoop, path_for_errors: []const u8, src: []const u8) !ExitCode { + pub fn initAndRunFromSource(ctx: bun.CLI.Command.Context, mini: *JSC.MiniEventLoop, path_for_errors: []const u8, src: []const u8) !ExitCode { bun.Analytics.Features.standalone_shell += 1; var arena = bun.ArenaAllocator.init(bun.default_allocator); defer arena.deinit();