Skip to content

Commit

Permalink
fix(misc): normalize paths when moving projects (#10944)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Jun 29, 2022
1 parent 769d10f commit 9e6e01b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/nx/src/generators/utils/project-configuration.ts
Expand Up @@ -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';

Expand Down Expand Up @@ -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')
)
);
}

Expand Down
@@ -1,4 +1,5 @@
import {
joinPathFragments,
offsetFromRoot,
ProjectConfiguration,
Tree,
Expand Down Expand Up @@ -28,7 +29,7 @@ function offsetFilePath(
return pathToFile;
}
const pathFromRoot = join(project.root, pathToFile);
return join(offset, pathFromRoot);
return joinPathFragments(offset, pathFromRoot);
}

/**
Expand Down
Expand Up @@ -34,7 +34,10 @@ export function updateProjectRootFiles(
}

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)) {
const ext = extname(file);
if (!allowedExt.includes(ext)) {
Expand Down

1 comment on commit 9e6e01b

@vercel
Copy link

@vercel vercel bot commented on 9e6e01b Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.