fix: update modules dir in monorepo, when hoisting is changed

PR #2802
This commit is contained in:
Zoltan Kochan
2020-08-27 18:03:19 +03:00
committed by GitHub
parent acc1782c6f
commit 6cc36c85c2
3 changed files with 18 additions and 5 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -76,6 +76,8 @@ export default async function recursive (
params: string[],
opts: RecursiveOptions & {
allowNew?: boolean
forceHoistPattern?: boolean
forcePublicHoistPattern?: boolean
ignoredPackages?: Set<string>
update?: boolean
useBetaCli?: boolean