@@ -8,13 +8,38 @@ beforeEach(async () => {
8
8
process . env . COREPACK_HOME = npath . fromPortablePath ( await xfs . mktempPromise ( ) ) ;
9
9
} ) ;
10
10
11
+ it ( `should refuse to download a package manager if the hash doesn't match` , async ( ) => {
12
+ await xfs . mktempPromise ( async cwd => {
13
+ await xfs . writeJsonPromise ( ppath . join ( cwd , `package.json` as Filename ) , {
14
+ packageManager : `yarn@1.22.4+sha1.deadbeef` ,
15
+ } ) ;
16
+
17
+ await expect ( runCli ( cwd , [ `yarn` , `--version` ] ) ) . resolves . toMatchObject ( {
18
+ exitCode : 1 ,
19
+ stdout : / M i s m a t c h h a s h e s / ,
20
+ } ) ;
21
+ } ) ;
22
+ } ) ;
23
+
11
24
const testedPackageManagers : Array < [ string , string ] > = [
12
25
[ `yarn` , `1.22.4` ] ,
26
+ [ `yarn` , `1.22.4+sha1.01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e` ] ,
27
+ [ `yarn` , `1.22.4+sha224.0d6eecaf4d82ec12566fdd97143794d0f0c317e0d652bd4d1b305430` ] ,
13
28
[ `yarn` , `2.0.0-rc.30` ] ,
29
+ [ `yarn` , `2.0.0-rc.30+sha1.4f0423b01bcb57f8e390b4e0f1990831f92dd1da` ] ,
30
+ [ `yarn` , `2.0.0-rc.30+sha224.0e7a64468c358596db21c401ffeb11b6534fce7367afd3ae640eadf1` ] ,
14
31
[ `yarn` , `3.0.0-rc.2` ] ,
32
+ [ `yarn` , `3.0.0-rc.2+sha1.694bdad81703169e203febd57f9dc97d3be867bd` ] ,
33
+ [ `yarn` , `3.0.0-rc.2+sha224.f83f6d1cbfac10ba6b516a62ccd2a72ccd857aa6c514d1cd7185ec60` ] ,
15
34
[ `pnpm` , `4.11.6` ] ,
35
+ [ `pnpm` , `4.11.6+sha1.7cffc04295f4db4740225c6c37cc345eb923c06a` ] ,
36
+ [ `pnpm` , `4.11.6+sha224.7783c4b01916b7a69e6ff05d328df6f83cb7f127e9c96be88739386d` ] ,
16
37
[ `pnpm` , `6.6.2` ] ,
38
+ [ `pnpm` , `6.6.2+sha1.7b4d6b176c1b93b5670ed94c24babb7d80c13854` ] ,
39
+ [ `pnpm` , `6.6.2+sha224.eb5c0acad3b0f40ecdaa2db9aa5a73134ad256e17e22d1419a2ab073` ] ,
17
40
[ `npm` , `6.14.2` ] ,
41
+ [ `npm` , `6.14.2+sha1.f057d35cd4792c4c511bb1fa332edb43143d07b0` ] ,
42
+ [ `npm` , `6.14.2+sha224.50512c1eb404900ee78586faa6d756b8d867ff46a328e6fb4cdf3a87` ] ,
18
43
] ;
19
44
20
45
for ( const [ name , version ] of testedPackageManagers ) {
@@ -26,7 +51,7 @@ for (const [name, version] of testedPackageManagers) {
26
51
27
52
await expect ( runCli ( cwd , [ name , `--version` ] ) ) . resolves . toMatchObject ( {
28
53
exitCode : 0 ,
29
- stdout : `${ version } \n` ,
54
+ stdout : `${ version . split ( `+` , 1 ) [ 0 ] } \n` ,
30
55
} ) ;
31
56
} ) ;
32
57
} ) ;
@@ -136,17 +161,17 @@ it(`should use the pinned version when local projects don't list any spec`, asyn
136
161
} ) ;
137
162
138
163
await expect ( runCli ( cwd , [ `yarn` , `--version` ] ) ) . resolves . toMatchObject ( {
139
- stdout : `${ config . definitions . yarn . default } \n` ,
164
+ stdout : `${ config . definitions . yarn . default . split ( `+` , 1 ) [ 0 ] } \n` ,
140
165
exitCode : 0 ,
141
166
} ) ;
142
167
143
168
await expect ( runCli ( cwd , [ `pnpm` , `--version` ] ) ) . resolves . toMatchObject ( {
144
- stdout : `${ config . definitions . pnpm . default } \n` ,
169
+ stdout : `${ config . definitions . pnpm . default . split ( `+` , 1 ) [ 0 ] } \n` ,
145
170
exitCode : 0 ,
146
171
} ) ;
147
172
148
173
await expect ( runCli ( cwd , [ `npm` , `--version` ] ) ) . resolves . toMatchObject ( {
149
- stdout : `${ config . definitions . npm . default } \n` ,
174
+ stdout : `${ config . definitions . npm . default . split ( `+` , 1 ) [ 0 ] } \n` ,
150
175
exitCode : 0 ,
151
176
} ) ;
152
177
} ) ;
0 commit comments