diff --git a/src/cli.zig b/src/cli.zig index 9389e03474..6883edd321 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -97,7 +97,6 @@ pub const ShellCompletions = @import("./cli/shell_completions.zig"); pub const UpdateCommand = @import("./cli/update_command.zig").UpdateCommand; pub const UpgradeCommand = @import("./cli/upgrade_command.zig").UpgradeCommand; pub const BunxCommand = @import("./cli/bunx_command.zig").BunxCommand; -pub const ExecCommand = @import("./cli/exec_command.zig").ExecCommand; pub const Arguments = struct { pub fn loader_resolver(in: string) !Api.Loader { @@ -783,11 +782,6 @@ pub const Arguments = struct { entry_points = entry_points[1..]; } }, - .ExecCommand => { - if (entry_points.len > 0 and (strings.eqlComptime(entry_points[0], "exec"))) { - entry_points = entry_points[1..]; - } - }, else => {}, } @@ -1312,7 +1306,6 @@ pub const Command = struct { RootCommandMatcher.case("run") => .RunCommand, RootCommandMatcher.case("help") => .HelpCommand, - RootCommandMatcher.case("exec") => .ExecCommand, // These are reserved for future use by Bun, so that someone // doing `bun deploy` to run a script doesn't accidentally break @@ -1854,12 +1847,6 @@ pub const Command = struct { Output.flush(); try HelpCommand.exec(allocator); }, - .ExecCommand => { - if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .ExecCommand) unreachable; - const ctx = try Command.Context.create(allocator, log, .ExecCommand); - try ExecCommand.exec(ctx); - return; - }, } } @@ -1983,7 +1970,6 @@ pub const Command = struct { UpdateCommand, UpgradeCommand, ReplCommand, - ExecCommand, ReservedCommand, pub fn params(comptime cmd: Tag) []const Arguments.ParamType { @@ -2185,10 +2171,6 @@ pub const Command = struct { Output.pretty("Usage: bun completions", .{}); Output.flush(); }, - Command.Tag.ExecCommand => { - Output.pretty("Usage: bun exec [...cmd]", .{}); - Output.flush(); - }, else => { HelpCommand.printWithReason(.explicit); }, diff --git a/src/cli/exec_command.zig b/src/cli/exec_command.zig deleted file mode 100644 index 92747f9cfa..0000000000 --- a/src/cli/exec_command.zig +++ /dev/null @@ -1,43 +0,0 @@ -const std = @import("std"); -const bun = @import("root").bun; -const string = bun.string; -const Output = bun.Output; -const Global = bun.Global; - -// TODO: shell escaping is hard and happens twice in some scenarios -// if '-c' is implemented here, make sure to use it in src/install/lifecycle_script_runner.zig -pub const ExecCommand = struct { - pub fn exec(ctx: bun.CLI.Command.Context) !void { - // - var commandline = std.ArrayList(u8).init(bun.default_allocator); - - for (bun.argv()[2..], 0..) |item, i| { - if (i > 0) try commandline.append(' '); - try commandline.appendSlice(item); - } - - const commandline_pretty = try std.fmt.allocPrint(bun.default_allocator, "\"{s}\"", .{commandline.items}); - - var ORIGINAL_PATH: string = ""; - var this_bundler: bun.bundler.Bundler = undefined; - const root_dir_info = try bun.RunCommand.configureEnvForRun(ctx, &this_bundler, null, true, false); - try bun.RunCommand.configurePathForRun(ctx, root_dir_info, &this_bundler, &ORIGINAL_PATH, root_dir_info.abs_path, false); - - var arena = bun.ArenaAllocator.init(bun.default_allocator); - const mini = bun.JSC.MiniEventLoop.initGlobal(this_bundler.env); - - const code = bun.shell.Interpreter.initAndRunFromFileSource(mini, &arena, commandline_pretty, commandline.items) catch |err| { - Output.prettyErrorln("error: Failed to run script {s} due to error {s}", .{ commandline_pretty, @errorName(err) }); - Global.exit(1); - }; - - if (code > 0) { - if (code != 2) { - Output.prettyErrorln("error: script \"{s}\" exited with code {d}", .{ commandline_pretty, code }); - Output.flush(); - } - - Global.exitWide(code); - } - } -};