File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
packages/auto-install/test Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,26 @@ const DIR = import.meta.dirname;
1212const cwd = path . join ( DIR , 'fixtures/yarn-bare' ) ;
1313const file = path . join ( cwd , 'output/bundle.js' ) ;
1414const input = path . join ( cwd , '../input.js' ) ;
15+ const pkgFile = path . join ( cwd , 'package.json' ) ;
1516
1617const PREV_CWD = process . cwd ( ) ;
1718
1819it ( 'yarn, bare' , async ( ) => {
1920 process . chdir ( cwd ) ;
21+ // Ensure Yarn classic does not traverse to the repo root and read its
22+ // packageManager (pnpm). When no local package.json exists, Yarn v1 will
23+ // use the nearest parent package.json and error out. Creating a minimal
24+ // local package.json with an explicit Yarn version avoids the Corepack gate.
25+ if ( ! fs . existsSync ( pkgFile ) ) {
26+ fs . writeFileSync (
27+ pkgFile ,
28+ JSON . stringify (
29+ { name :
'auto-install-yarn-bare-fixture' , private :
true , packageManager :
'[email protected] ' } , 30+ null ,
31+ 2
32+ )
33+ ) ;
34+ }
2035 const bundle = await rollup ( {
2136 input,
2237 // @ts -expect-error - rollup() ignores output here but tests kept it historically
Original file line number Diff line number Diff line change @@ -12,11 +12,25 @@ const DIR = import.meta.dirname;
1212const cwd = path . join ( DIR , 'fixtures/yarn' ) ;
1313const file = path . join ( cwd , 'output/bundle.js' ) ;
1414const input = path . join ( cwd , '../input.js' ) ;
15+ const pkgFile = path . join ( cwd , 'package.json' ) ;
1516
1617const PREV_CWD = process . cwd ( ) ;
1718
1819it ( 'yarn' , async ( ) => {
1920 process . chdir ( cwd ) ;
21+ // Pre-create a local package.json with an explicit Yarn v1 requirement so
22+ // the Yarn shim (Corepack) doesn't traverse to the repo root and pick up
23+ // the root packageManager (pnpm), which would cause a usage error.
24+ if ( ! fs . existsSync ( pkgFile ) ) {
25+ fs . writeFileSync (
26+ pkgFile ,
27+ JSON . stringify (
28+ { name :
'auto-install-yarn-fixture' , private :
true , packageManager :
'[email protected] ' } , 29+ null ,
30+ 2
31+ )
32+ ) ;
33+ }
2034 const bundle = await rollup ( {
2135 input,
2236 // @ts -expect-error - rollup() ignores output here but tests kept it historically
You can’t perform that action at this time.
0 commit comments