remove bun exec

This commit is contained in:
Meghan Denny
2024-03-20 01:28:38 -07:00
parent 203022e04c
commit 5332a17551
2 changed files with 0 additions and 61 deletions

View File

@@ -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("<b>Usage<r>: <b><green>bun completions<r>", .{});
Output.flush();
},
Command.Tag.ExecCommand => {
Output.pretty("<b>Usage<r>: <b><green>bun exec [...cmd]<r>", .{});
Output.flush();
},
else => {
HelpCommand.printWithReason(.explicit);
},

View File

@@ -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("<r><red>error<r>: Failed to run script <b>{s}<r> due to error <b>{s}<r>", .{ commandline_pretty, @errorName(err) });
Global.exit(1);
};
if (code > 0) {
if (code != 2) {
Output.prettyErrorln("<r><red>error<r><d>:<r> script <b>\"{s}\"<r> exited with code {d}<r>", .{ commandline_pretty, code });
Output.flush();
}
Global.exitWide(code);
}
}
};