File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
crates/volta-core/src/tool/yarn Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -86,13 +86,25 @@ fn fetch_yarn_index(package: &str) -> Fallible<(String, PackageIndex)> {
8686}
8787
8888fn 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) ;
You can’t perform that action at this time.
0 commit comments