aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-10-12 15:02:05 -0700
committerGravatar GitHub <noreply@github.com> 2023-10-12 15:02:05 -0700
commit691cf338c2a88fd2629f50934fe35fcb5bd08ae2 (patch)
treec43d3b3f17955cf3c0787e262596bc951e1a2696 /src
parentbeb746e5eaf7681212e9f6d72c782abe7789471d (diff)
downloadbun-691cf338c2a88fd2629f50934fe35fcb5bd08ae2.tar.gz
bun-691cf338c2a88fd2629f50934fe35fcb5bd08ae2.tar.zst
bun-691cf338c2a88fd2629f50934fe35fcb5bd08ae2.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/cli/bunx_command.zig24
-rw-r--r--src/install/install.zig1
2 files changed, 13 insertions, 12 deletions
diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig
index dba2d5664..e7f35d10d 100644
--- a/src/cli/bunx_command.zig
+++ b/src/cli/bunx_command.zig
@@ -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;
diff --git a/src/install/install.zig b/src/install/install.zig
index 67fbf6b6b..6bff738df 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -6370,7 +6370,6 @@ pub const PackageManager = struct {
request.name = allocator.dupe(u8, name) catch unreachable;
request.name_hash = String.Builder.stringHash(name);
} else if (version.tag == .github and version.value.github.committish.isEmpty()) {
- request.name = input;
request.name_hash = String.Builder.stringHash(version.literal.slice(input));
} else {
request.name_hash = String.Builder.stringHash(version.literal.slice(input));