Skip to content

Commit 18c3681

Browse files
authored
fix(core): path comparison across OS for getProjectNameFromDirPath (#6433)
ISSUES CLOSED: #6406
1 parent 66851cc commit 18c3681

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/workspace/src/utilities/generate-globs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { joinPathFragments } from '@nrwl/devkit';
2+
import { appRootPath } from '@nrwl/tao/src/utils/app-root';
23
import { relative, resolve } from 'path';
34
import { readCachedProjectGraph } from '../core/project-graph';
4-
import { appRootPath } from './app-root';
55
import {
66
getProjectNameFromDirPath,
77
getSourceDirOfDependentProjects,

packages/workspace/src/utilities/project-graph-utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ProjectGraph, ProjectGraphNode } from '@nrwl/devkit';
1+
import { normalizePath, ProjectGraph, ProjectGraphNode } from '@nrwl/devkit';
22
import { relative } from 'path';
33
import { readCachedProjectGraph } from '../core/project-graph';
44

@@ -45,10 +45,13 @@ export function getProjectNameFromDirPath(
4545
) {
4646
let parentNodeName = null;
4747
for (const [nodeName, node] of Object.entries(projectGraph.nodes)) {
48-
const relativePath = relative(node.data.root, projRelativeDirPath);
48+
const normalizedRootPath = normalizePath(node.data.root);
49+
const normalizedProjRelPath = normalizePath(projRelativeDirPath);
50+
51+
const relativePath = relative(normalizedRootPath, normalizedProjRelPath);
4952
const isMatch = relativePath && !relativePath.startsWith('..');
5053

51-
if (isMatch || node.data.root === projRelativeDirPath) {
54+
if (isMatch || normalizedRootPath === normalizedProjRelPath) {
5255
parentNodeName = nodeName;
5356
break;
5457
}

0 commit comments

Comments
 (0)