mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix(npm): don't break on npm workspace dir with a period (#30483)
This commit is contained in:
parent
99ba29df74
commit
5bdaf47eeb
2 changed files with 35 additions and 2 deletions
|
@ -514,6 +514,17 @@ describe('modules/manager/npm/post-update/npm', () => {
|
||||||
workspacesPackages: ['docs/*', 'web/*'],
|
workspacesPackages: ['docs/*', 'web/*'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
packageFile: 'some-dir/docs/dir.has.period/package.json',
|
||||||
|
packageName: 'hello',
|
||||||
|
depType: 'dependencies',
|
||||||
|
newVersion: '1.1.1',
|
||||||
|
newValue: '^1.0.0',
|
||||||
|
isLockfileUpdate: true,
|
||||||
|
managerData: {
|
||||||
|
workspacesPackages: ['docs/*', 'web/*'],
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
packageFile: 'some-missing-dir/docs/a/package.json',
|
packageFile: 'some-missing-dir/docs/a/package.json',
|
||||||
packageName: 'hello',
|
packageName: 'hello',
|
||||||
|
@ -549,6 +560,9 @@ describe('modules/manager/npm/post-update/npm', () => {
|
||||||
{
|
{
|
||||||
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=web/b xmldoc@2.2.0 hello@1.1.1',
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=web/b xmldoc@2.2.0 hello@1.1.1',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=docs/dir.has.period hello@1.1.1',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts chalk@9.4.8 postcss@8.4.8',
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts chalk@9.4.8 postcss@8.4.8',
|
||||||
|
@ -584,6 +598,9 @@ describe('modules/manager/npm/post-update/npm', () => {
|
||||||
{
|
{
|
||||||
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=web/b xmldoc@2.2.0 hello@1.1.1',
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=web/b xmldoc@2.2.0 hello@1.1.1',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts --workspace=docs/dir.has.period hello@1.1.1',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts chalk@9.4.8 postcss@8.4.8',
|
cmd: 'npm install --package-lock-only --no-audit --ignore-scripts chalk@9.4.8 postcss@8.4.8',
|
||||||
|
@ -689,8 +706,20 @@ describe('modules/manager/npm/post-update/npm', () => {
|
||||||
},
|
},
|
||||||
workspace: 'docs/a',
|
workspace: 'docs/a',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
packageFile: 'docs/dir.has.period/package.json',
|
||||||
|
packageName: 'hello',
|
||||||
|
depType: 'dependencies',
|
||||||
|
newVersion: '1.1.1',
|
||||||
|
newValue: '^1.0.0',
|
||||||
|
isLockfileUpdate: true,
|
||||||
|
managerData: {
|
||||||
|
workspacesPackages: ['docs/*', 'web/*'],
|
||||||
|
},
|
||||||
|
workspace: 'docs/dir.has.period',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
workspaces: new Set(['docs/a', 'web/b']),
|
workspaces: new Set(['docs/a', 'web/b', 'docs/dir.has.period']),
|
||||||
rootDeps: new Set(['chalk@9.4.8', 'postcss@8.4.8']),
|
rootDeps: new Set(['chalk@9.4.8', 'postcss@8.4.8']),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -291,7 +291,11 @@ export function divideWorkspaceAndRootDeps(
|
||||||
);
|
);
|
||||||
|
|
||||||
// workspaceDir = packageFileDir - lockFileDir
|
// workspaceDir = packageFileDir - lockFileDir
|
||||||
const workspaceDir = trimSlashes(packageFileDir.replace(lockFileDir, ''));
|
const workspaceDir = trimSlashes(
|
||||||
|
packageFileDir.startsWith(lockFileDir)
|
||||||
|
? packageFileDir.slice(lockFileDir.length)
|
||||||
|
: packageFileDir,
|
||||||
|
);
|
||||||
|
|
||||||
if (is.nonEmptyString(workspaceDir)) {
|
if (is.nonEmptyString(workspaceDir)) {
|
||||||
let workspaceName: string | undefined;
|
let workspaceName: string | undefined;
|
||||||
|
|
Loading…
Reference in a new issue