Skip to content

Commit 08a978b

Browse files
committed
also check both registries for custom tags
1 parent 8fa0e54 commit 08a978b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

crates/volta-core/src/tool/yarn/resolve.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,25 @@ fn fetch_yarn_index(package: &str) -> Fallible<(String, PackageIndex)> {
8686
}
8787

8888
fn resolve_custom_tag(tag: String) -> Fallible<Version> {
89-
// yarn2 and yarn3 are under "@yarnpkg/cli-dist" instead of "yarn"
90-
let package: &str = match env::var_os("VOLTA_FEATURE_YARN_3") {
91-
Some(_) => "@yarnpkg/cli-dist",
92-
None => "yarn",
93-
};
94-
let (url, mut index) = fetch_yarn_index(package)?;
89+
if env::var_os("VOLTA_FEATURE_YARN_3").is_some() {
90+
// first try yarn2+, which uses "@yarnpkg/cli-dist" instead of "yarn"
91+
let (url, mut index) = fetch_yarn_index("@yarnpkg/cli-dist")?;
92+
93+
let matches_yarn_3 = VersionReq::parse(">=3").unwrap();
94+
if let Some(version) = index.tags.remove(&tag) {
95+
debug!("Found yarn@{} matching tag '{}' from {}", version, tag, url);
96+
if matches_yarn_3.matches(&version) {
97+
return Err(ErrorKind::Yarn2NotSupported.into());
98+
}
99+
return Ok(version);
100+
}
101+
debug!(
102+
"Did not find yarn matching tag '{}' from @yarnpkg/cli-dist",
103+
tag
104+
);
105+
}
95106

107+
let (url, mut index) = fetch_yarn_index("yarn")?;
96108
match index.tags.remove(&tag) {
97109
Some(version) => {
98110
debug!("Found yarn@{} matching tag '{}' from {}", version, tag, url);

0 commit comments

Comments
 (0)