From 9e6e01b6592aedbcae7b719daf6dbf67411b77cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 29 Jun 2022 11:45:36 +0100 Subject: [PATCH] fix(misc): normalize paths when moving projects (#10944) --- .../nx/src/generators/utils/project-configuration.ts | 10 ++++++---- .../src/generators/move/lib/update-eslintrc-json.ts | 3 ++- .../generators/move/lib/update-project-root-files.ts | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/nx/src/generators/utils/project-configuration.ts b/packages/nx/src/generators/utils/project-configuration.ts index f7a977369e7b4..f57a4143899c1 100644 --- a/packages/nx/src/generators/utils/project-configuration.ts +++ b/packages/nx/src/generators/utils/project-configuration.ts @@ -12,7 +12,7 @@ import { reformattedWorkspaceJsonOrNull, toNewFormat, } from '../../config/workspaces'; -import { joinPathFragments } from '../../utils/path'; +import { joinPathFragments, normalizePath } from '../../utils/path'; import type { Tree } from '../tree'; @@ -319,9 +319,11 @@ export function getRelativeProjectJsonSchemaPath( tree: Tree, project: ProjectConfiguration ): string { - return relative( - join(tree.root, project.root), - join(tree.root, 'node_modules/nx/schemas/project-schema.json') + return normalizePath( + relative( + join(tree.root, project.root), + join(tree.root, 'node_modules/nx/schemas/project-schema.json') + ) ); } diff --git a/packages/workspace/src/generators/move/lib/update-eslintrc-json.ts b/packages/workspace/src/generators/move/lib/update-eslintrc-json.ts index 45492ac30f9d8..ac903122de28b 100644 --- a/packages/workspace/src/generators/move/lib/update-eslintrc-json.ts +++ b/packages/workspace/src/generators/move/lib/update-eslintrc-json.ts @@ -1,4 +1,5 @@ import { + joinPathFragments, offsetFromRoot, ProjectConfiguration, Tree, @@ -28,7 +29,7 @@ function offsetFilePath( return pathToFile; } const pathFromRoot = join(project.root, pathToFile); - return join(offset, pathFromRoot); + return joinPathFragments(offset, pathFromRoot); } /** diff --git a/packages/workspace/src/generators/move/lib/update-project-root-files.ts b/packages/workspace/src/generators/move/lib/update-project-root-files.ts index fd83586a68c37..22d377088c8ff 100644 --- a/packages/workspace/src/generators/move/lib/update-project-root-files.ts +++ b/packages/workspace/src/generators/move/lib/update-project-root-files.ts @@ -34,7 +34,10 @@ export function updateProjectRootFiles( } const dots = /\./g; - const regex = new RegExp(oldRelativeRoot.replace(dots, '\\.'), 'g'); + const regex = new RegExp( + `(?