mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(npm): better detect workspace packages (#25692)
This commit is contained in:
parent
3788950167
commit
16b3862821
2 changed files with 29 additions and 8 deletions
|
@ -459,6 +459,17 @@ describe('modules/manager/npm/post-update/npm', () => {
|
|||
workspacesPackages: ['docs/*', 'web/*'],
|
||||
},
|
||||
},
|
||||
{
|
||||
packageFile: 'some-missing-dir/docs/a/package.json',
|
||||
packageName: 'hello',
|
||||
depType: 'dependencies',
|
||||
newVersion: '1.1.1',
|
||||
newValue: '^1.0.0',
|
||||
isLockfileUpdate: true,
|
||||
managerData: {
|
||||
workspacesPackages: ['docs/*', 'web/*'],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
it('workspace in sub-folder', async () => {
|
||||
|
|
|
@ -265,18 +265,28 @@ export function divideWorkspaceAndRootDeps(
|
|||
// stop when the first match is found and
|
||||
// add workspaceDir to workspaces set and upgrade object
|
||||
for (const workspacePattern of workspacePatterns) {
|
||||
if (minimatch(workspacePattern).match(workspaceDir)) {
|
||||
const massagedPattern = (workspacePattern as string).replace(
|
||||
/^\.\//,
|
||||
'',
|
||||
);
|
||||
if (minimatch(massagedPattern).match(workspaceDir)) {
|
||||
workspaceName = workspaceDir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (
|
||||
workspaceName &&
|
||||
!rootDeps.has(upgrade.managerData.packageKey) // prevent same dep from existing in root and workspace
|
||||
) {
|
||||
workspaces.add(workspaceName);
|
||||
upgrade.workspace = workspaceName;
|
||||
lockWorkspacesUpdates.push(upgrade);
|
||||
if (workspaceName) {
|
||||
if (
|
||||
!rootDeps.has(upgrade.managerData.packageKey) // prevent same dep from existing in root and workspace
|
||||
) {
|
||||
workspaces.add(workspaceName);
|
||||
upgrade.workspace = workspaceName;
|
||||
lockWorkspacesUpdates.push(upgrade);
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
{ workspacePatterns, workspaceDir },
|
||||
'workspaceDir not found',
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue