diff --git a/.changeset/lemon-ties-add.md b/.changeset/lemon-ties-add.md new file mode 100644 index 0000000000..c18aa29969 --- /dev/null +++ b/.changeset/lemon-ties-add.md @@ -0,0 +1,8 @@ +--- +"@pnpm/plugin-commands-installation": patch +--- + +`pnpm install -r` should recreate the modules directory +if the hoisting patterns were updated in a local config file. +The hoisting patterns are configure via the `hoist-pattern` +and `public-hoist-pattern` settings. diff --git a/packages/plugin-commands-installation/src/installDeps.ts b/packages/plugin-commands-installation/src/installDeps.ts index c12f050e58..61b154e48b 100644 --- a/packages/plugin-commands-installation/src/installDeps.ts +++ b/packages/plugin-commands-installation/src/installDeps.ts @@ -107,11 +107,17 @@ when running add/update with the --workspace option') devDependencies: true, optionalDependencies: true, } + const forceHoistPattern = typeof opts.rawLocalConfig['hoist-pattern'] !== 'undefined' || + typeof opts.rawLocalConfig['hoist'] !== 'undefined' + const forcePublicHoistPattern = typeof opts.rawLocalConfig['shamefully-hoist'] !== 'undefined' || + typeof opts.rawLocalConfig['public-hoist-pattern'] !== 'undefined' if (opts.recursive && opts.allProjects && opts.selectedProjectsGraph && opts.workspaceDir) { await recursive(opts.allProjects, params, { ...opts, + forceHoistPattern, + forcePublicHoistPattern, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir, }, @@ -134,6 +140,8 @@ when running add/update with the --workspace option') const store = await createOrConnectStoreController(opts) const installOpts = { ...opts, + forceHoistPattern, + forcePublicHoistPattern, // In case installation is done in a multi-package repository // The dependencies should be built first, // so ignoring scripts for now @@ -144,11 +152,6 @@ when running add/update with the --workspace option') storeController: store.ctrl, storeDir: store.dir, workspacePackages, - - forceHoistPattern: typeof opts.rawLocalConfig['hoist-pattern'] !== 'undefined' || - typeof opts.rawLocalConfig['hoist'] !== 'undefined', - forcePublicHoistPattern: typeof opts.rawLocalConfig['shamefully-hoist'] !== 'undefined' || - typeof opts.rawLocalConfig['public-hoist-pattern'] !== 'undefined', } if (!opts.ignorePnpmfile) { installOpts['hooks'] = requireHooks(opts.lockfileDir ?? dir, opts) diff --git a/packages/plugin-commands-installation/src/recursive.ts b/packages/plugin-commands-installation/src/recursive.ts index 8cd1b2a64b..c75bb165b8 100755 --- a/packages/plugin-commands-installation/src/recursive.ts +++ b/packages/plugin-commands-installation/src/recursive.ts @@ -76,6 +76,8 @@ export default async function recursive ( params: string[], opts: RecursiveOptions & { allowNew?: boolean + forceHoistPattern?: boolean + forcePublicHoistPattern?: boolean ignoredPackages?: Set update?: boolean useBetaCli?: boolean