@@ -114,13 +114,15 @@ const {run, setFlags, examples} = buildSubCommands('policies', {
114
114
115
115
let bundleUrl ;
116
116
let bundleVersion ;
117
+ let isV2 = false ;
117
118
118
119
if ( range === 'nightly' || range === 'nightlies' ) {
119
120
bundleUrl = 'https://nightly.yarnpkg.com/latest.js' ;
120
121
bundleVersion = 'nightly' ;
121
122
} else if ( range === 'berry' || range === 'v2' || range === '2' ) {
122
123
bundleUrl = 'https://github.com/yarnpkg/berry/raw/master/packages/berry-cli/bin/berry.js' ;
123
124
bundleVersion = 'berry' ;
125
+ isV2 = true ;
124
126
} else {
125
127
const releases = await fetchReleases ( config , {
126
128
includePrereleases : allowRc ,
@@ -145,18 +147,29 @@ const {run, setFlags, examples} = buildSubCommands('policies', {
145
147
reporter . log ( `Downloading ${ chalk . green ( bundleUrl ) } ...` ) ;
146
148
147
149
const bundle = await fetchBundle ( config , bundleUrl ) ;
148
- const rc = getRcConfigForFolder ( config . lockfileFolder ) ;
149
150
150
151
const yarnPath = path . resolve ( config . lockfileFolder , `.yarn/releases/yarn-${ bundleVersion } .js` ) ;
151
152
reporter . log ( `Saving it into ${ chalk . magenta ( yarnPath ) } ...` ) ;
152
153
await fs . mkdirp ( path . dirname ( yarnPath ) ) ;
153
154
await fs . writeFile ( yarnPath , bundle ) ;
154
155
await fs . chmod ( yarnPath , 0o755 ) ;
155
156
156
- const rcPath = `${ config . lockfileFolder } /.yarnrc` ;
157
- reporter . log ( `Updating ${ chalk . magenta ( rcPath ) } ...` ) ;
158
- rc [ 'yarn-path' ] = path . relative ( config . lockfileFolder , yarnPath ) ;
159
- await fs . writeFilePreservingEol ( rcPath , `${ stringify ( rc ) } \n` ) ;
157
+ const targetPath = path . relative ( config . lockfileFolder , yarnPath ) . replace ( / \\ / g, '/' ) ;
158
+
159
+ if ( isV2 ) {
160
+ const rcPath = `${ config . lockfileFolder } /.yarnrc.yml` ;
161
+ reporter . log ( `Updating ${ chalk . magenta ( rcPath ) } ...` ) ;
162
+
163
+ await fs . writeFilePreservingEol ( rcPath , `yarnPath: ${ JSON . stringify ( yarnPath ) } \n` ) ;
164
+ } else {
165
+ const rcPath = `${ config . lockfileFolder } /.yarnrc` ;
166
+ reporter . log ( `Updating ${ chalk . magenta ( rcPath ) } ...` ) ;
167
+
168
+ const rc = getRcConfigForFolder ( config . lockfileFolder ) ;
169
+ rc [ 'yarn-path' ] = targetPath ;
170
+
171
+ await fs . writeFilePreservingEol ( rcPath , `${ stringify ( rc ) } \n` ) ;
172
+ }
160
173
161
174
reporter . log ( `Done!` ) ;
162
175
} ,
0 commit comments