Support bunx --version (#10701)

This commit is contained in:
Ashcon Partovi
2024-04-30 11:29:17 -07:00
committed by GitHub
parent efd4e15f4c
commit 32bf5eb444
5 changed files with 98 additions and 18 deletions

View File

@@ -208,9 +208,8 @@ pub const Arguments = struct {
pub const run_params = run_only_params ++ runtime_params_ ++ transpiler_params_ ++ base_params_;
const bunx_commands = [_]ParamType{
clap.parseParam("--silent Don't print the script command") catch unreachable,
clap.parseParam("-b, --bun Force a script or package to use Bun's runtime instead of Node.js (via symlinking node)") catch unreachable,
};
} ++ auto_only_params;
const build_only_params = [_]ParamType{
clap.parseParam("--compile Generate a standalone Bun executable containing your bundled code") catch unreachable,
@@ -251,18 +250,6 @@ pub const Arguments = struct {
};
pub const test_params = test_only_params ++ runtime_params_ ++ transpiler_params_ ++ base_params_;
fn printVersionAndExit() noreturn {
@setCold(true);
Output.writer().writeAll(Global.package_json_version ++ "\n") catch {};
Global.exit(0);
}
fn printRevisionAndExit() noreturn {
@setCold(true);
Output.writer().writeAll(Global.package_json_version_with_revision ++ "\n") catch {};
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 {
var config_file = switch (bun.sys.openA(config_path, std.os.O.RDONLY, 0)) {
.result => |fd| fd.asFile(),
@@ -2341,3 +2328,15 @@ pub const Command = struct {
});
};
};
pub fn printVersionAndExit() noreturn {
@setCold(true);
Output.writer().writeAll(Global.package_json_version ++ "\n") catch {};
Global.exit(0);
}
pub fn printRevisionAndExit() noreturn {
@setCold(true);
Output.writer().writeAll(Global.package_json_version_with_revision ++ "\n") catch {};
Global.exit(0);
}