mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Add bun pm view command (#19841)
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,7 @@ const DefaultTrustedCommand = @import("./pm_trusted_command.zig").DefaultTrusted
|
||||
const Environment = bun.Environment;
|
||||
pub const PackCommand = @import("./pack_command.zig").PackCommand;
|
||||
const Npm = Install.Npm;
|
||||
const PmViewCommand = @import("./pm_view_command.zig");
|
||||
const File = bun.sys.File;
|
||||
|
||||
const ByName = struct {
|
||||
@@ -126,6 +127,7 @@ pub const PackageManagerCommand = struct {
|
||||
\\ <b><green>bun pm<r> <blue>ls<r> list the dependency tree according to the current lockfile
|
||||
\\ <d>└<r> <cyan>--all<r> list the entire dependency tree according to the current lockfile
|
||||
\\ <b><green>bun pm<r> <blue>whoami<r> print the current npm username
|
||||
\\ <b><green>bun pm<r> <blue>view<r> <d>name[@version]<r> view package metadata from the registry
|
||||
\\ <b><green>bun pm<r> <blue>hash<r> generate & print the hash of the current lockfile
|
||||
\\ <b><green>bun pm<r> <blue>hash-string<r> print the string used to hash the lockfile
|
||||
\\ <b><green>bun pm<r> <blue>hash-print<r> print the hash stored in the current lockfile
|
||||
@@ -192,6 +194,10 @@ pub const PackageManagerCommand = struct {
|
||||
};
|
||||
Output.println("{s}", .{username});
|
||||
Global.exit(0);
|
||||
} else if (strings.eqlComptime(subcommand, "view")) {
|
||||
const property_path = if (pm.options.positionals.len > 2) pm.options.positionals[2] else null;
|
||||
try PmViewCommand.view(ctx.allocator, pm, if (pm.options.positionals.len > 1) pm.options.positionals[1] else "", property_path, pm.options.json_output);
|
||||
Global.exit(0);
|
||||
} else if (strings.eqlComptime(subcommand, "bin")) {
|
||||
const output_path = Path.joinAbs(Fs.FileSystem.instance.top_level_dir, .auto, bun.asByteSlice(pm.options.bin_path));
|
||||
Output.prettyln("{s}", .{output_path});
|
||||
|
||||
Reference in New Issue
Block a user