fix(misc): normalize paths when moving projects (#10944)
This commit is contained in:
parent
769d10fd01
commit
9e6e01b659
@ -12,7 +12,7 @@ import {
|
|||||||
reformattedWorkspaceJsonOrNull,
|
reformattedWorkspaceJsonOrNull,
|
||||||
toNewFormat,
|
toNewFormat,
|
||||||
} from '../../config/workspaces';
|
} from '../../config/workspaces';
|
||||||
import { joinPathFragments } from '../../utils/path';
|
import { joinPathFragments, normalizePath } from '../../utils/path';
|
||||||
|
|
||||||
import type { Tree } from '../tree';
|
import type { Tree } from '../tree';
|
||||||
|
|
||||||
@ -319,9 +319,11 @@ export function getRelativeProjectJsonSchemaPath(
|
|||||||
tree: Tree,
|
tree: Tree,
|
||||||
project: ProjectConfiguration
|
project: ProjectConfiguration
|
||||||
): string {
|
): string {
|
||||||
return relative(
|
return normalizePath(
|
||||||
join(tree.root, project.root),
|
relative(
|
||||||
join(tree.root, 'node_modules/nx/schemas/project-schema.json')
|
join(tree.root, project.root),
|
||||||
|
join(tree.root, 'node_modules/nx/schemas/project-schema.json')
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
joinPathFragments,
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
ProjectConfiguration,
|
ProjectConfiguration,
|
||||||
Tree,
|
Tree,
|
||||||
@ -28,7 +29,7 @@ function offsetFilePath(
|
|||||||
return pathToFile;
|
return pathToFile;
|
||||||
}
|
}
|
||||||
const pathFromRoot = join(project.root, pathToFile);
|
const pathFromRoot = join(project.root, pathToFile);
|
||||||
return join(offset, pathFromRoot);
|
return joinPathFragments(offset, pathFromRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -34,7 +34,10 @@ export function updateProjectRootFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dots = /\./g;
|
const dots = /\./g;
|
||||||
const regex = new RegExp(oldRelativeRoot.replace(dots, '\\.'), 'g');
|
const regex = new RegExp(
|
||||||
|
`(?<!\\.\\.\\/)${oldRelativeRoot.replace(dots, '\\.')}(?!\\/\\.\\.)`,
|
||||||
|
'g'
|
||||||
|
);
|
||||||
for (const file of tree.children(schema.relativeToRootDestination)) {
|
for (const file of tree.children(schema.relativeToRootDestination)) {
|
||||||
const ext = extname(file);
|
const ext = extname(file);
|
||||||
if (!allowedExt.includes(ext)) {
|
if (!allowedExt.includes(ext)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user