File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -572,6 +572,28 @@ export async function applyPackageOverrides(
572572 ...pkg . pnpm . overrides ,
573573 ...overrides ,
574574 }
575+ // check `overrides` in pnpm-workspace.yaml
576+ const pnpmWorkspaceFile = path . join ( dir , 'pnpm-workspace.yaml' )
577+ if ( fs . existsSync ( pnpmWorkspaceFile ) ) {
578+ const pnpmWorkspaceContent = await fs . promises . readFile (
579+ pnpmWorkspaceFile ,
580+ 'utf-8' ,
581+ )
582+ if ( / ^ o v e r r i d e s : / m. test ( pnpmWorkspaceContent ) ) {
583+ delete pkg . pnpm . overrides // remove pnpm.overrides from package.json so that pnpm-workspace.yaml's one is used
584+ const newContent = pnpmWorkspaceContent . replace (
585+ / ^ o v e r r i d e s : \n / m,
586+ ( ) =>
587+ `overrides:\n${ Object . entries ( overrides )
588+ . map (
589+ ( [ name , version ] ) =>
590+ ` ${ JSON . stringify ( name ) } : ${ JSON . stringify ( version ) } \n` ,
591+ )
592+ . join ( '' ) } `,
593+ )
594+ await fs . promises . writeFile ( pnpmWorkspaceFile , newContent , 'utf-8' )
595+ }
596+ }
575597 } else if ( pm === 'yarn' ) {
576598 pkg . resolutions = {
577599 ...pkg . resolutions ,
You can’t perform that action at this time.
0 commit comments