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/*'],
|
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 () => {
|
it('workspace in sub-folder', async () => {
|
||||||
|
|
|
@ -265,19 +265,29 @@ export function divideWorkspaceAndRootDeps(
|
||||||
// stop when the first match is found and
|
// stop when the first match is found and
|
||||||
// add workspaceDir to workspaces set and upgrade object
|
// add workspaceDir to workspaces set and upgrade object
|
||||||
for (const workspacePattern of workspacePatterns) {
|
for (const workspacePattern of workspacePatterns) {
|
||||||
if (minimatch(workspacePattern).match(workspaceDir)) {
|
const massagedPattern = (workspacePattern as string).replace(
|
||||||
|
/^\.\//,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
if (minimatch(massagedPattern).match(workspaceDir)) {
|
||||||
workspaceName = workspaceDir;
|
workspaceName = workspaceDir;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (workspaceName) {
|
||||||
if (
|
if (
|
||||||
workspaceName &&
|
|
||||||
!rootDeps.has(upgrade.managerData.packageKey) // prevent same dep from existing in root and workspace
|
!rootDeps.has(upgrade.managerData.packageKey) // prevent same dep from existing in root and workspace
|
||||||
) {
|
) {
|
||||||
workspaces.add(workspaceName);
|
workspaces.add(workspaceName);
|
||||||
upgrade.workspace = workspaceName;
|
upgrade.workspace = workspaceName;
|
||||||
lockWorkspacesUpdates.push(upgrade);
|
lockWorkspacesUpdates.push(upgrade);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn(
|
||||||
|
{ workspacePatterns, workspaceDir },
|
||||||
|
'workspaceDir not found',
|
||||||
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue