mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 06:12:08 +00:00
fix editing package json when adding github dependency (#6432)
* fix package name added to package json * check for github tag * remove alloc * some tests * fix test
This commit is contained in:
@@ -236,6 +236,8 @@ pub const BunxCommand = struct {
|
||||
|
||||
const initial_bin_name = if (strings.eqlComptime(update_request.name, "typescript"))
|
||||
"tsc"
|
||||
else if (update_request.version.tag == .github)
|
||||
update_request.version.value.github.repo.slice(update_request.version_buf)
|
||||
else if (strings.lastIndexOfChar(update_request.name, '/')) |index|
|
||||
update_request.name[index + 1 ..]
|
||||
else
|
||||
@@ -262,19 +264,19 @@ pub const BunxCommand = struct {
|
||||
else
|
||||
update_request.version.literal.slice(update_request.version_buf);
|
||||
|
||||
const package_fmt: []const u8 = brk: {
|
||||
if (!strings.eql(update_request.version_buf, update_request.name)) {
|
||||
break :brk try std.fmt.allocPrint(
|
||||
ctx.allocator,
|
||||
"{s}@{s}",
|
||||
.{
|
||||
update_request.name,
|
||||
display_version,
|
||||
},
|
||||
);
|
||||
const package_fmt = brk: {
|
||||
if (update_request.version.tag == .github) {
|
||||
break :brk update_request.version.literal.slice(update_request.version_buf);
|
||||
}
|
||||
|
||||
break :brk update_request.name;
|
||||
break :brk try std.fmt.allocPrint(
|
||||
ctx.allocator,
|
||||
"{s}@{s}",
|
||||
.{
|
||||
update_request.name,
|
||||
display_version,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const PATH_FOR_BIN_DIRS = PATH;
|
||||
|
||||
Reference in New Issue
Block a user