mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
[bun install] Strip leading v in versions
This commit is contained in:
@@ -351,6 +351,21 @@ pub const Version = struct {
|
||||
return .dist_tag;
|
||||
},
|
||||
|
||||
// Dependencies can start with v
|
||||
// v1.0.0 is the same as 1.0.0
|
||||
// However, a github repo or a tarball could start with v
|
||||
'v' => {
|
||||
if (isTarball(dependency)) {
|
||||
return .tarball;
|
||||
}
|
||||
|
||||
if (isGithubRepoPath(dependency)) {
|
||||
return .github;
|
||||
}
|
||||
|
||||
return .npm;
|
||||
},
|
||||
|
||||
// file:
|
||||
'f' => {
|
||||
if (isTarball(dependency))
|
||||
@@ -468,6 +483,13 @@ pub fn parse(allocator: *std.mem.Allocator, dependency_: string, sliced: *const
|
||||
dependency = dependency[4..];
|
||||
}
|
||||
|
||||
// Strip single leading v
|
||||
// v1.0.0 -> 1.0.0
|
||||
// note: "vx" is valid, it becomes "x". "yarn add react@vx" -> "yarn add react@x" -> "yarn add react@17.0.2"
|
||||
if (tag == .npm and dependency.len > 1 and dependency[0] == 'v') {
|
||||
dependency = dependency[1..];
|
||||
}
|
||||
|
||||
return parseWithTag(
|
||||
allocator,
|
||||
dependency,
|
||||
|
||||
Reference in New Issue
Block a user