Skip to content

Commit a3e65d0

Browse files
committed
feat(core): validate that project root starts with workspace root
1 parent 83e8107 commit a3e65d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libs/native-federation-core/src/lib/utils/package-info.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function getPackageInfo(
5454
workspaceRoot = normalize(workspaceRoot, true);
5555
projectRoot = normalize(projectRoot, true);
5656

57+
if (!projectRoot.startsWith(workspaceRoot)) {
58+
throw new Error(`Workspace folder ${workspaceRoot} needs to be a parent of the project folder ${projectRoot}`);
59+
}
60+
5761
let currentPath = projectRoot;
5862

5963
while (workspaceRoot !== currentPath) {
@@ -81,7 +85,6 @@ export function _getPackageInfo(
8185
currentPath: string,
8286
): PackageInfo | null {
8387

84-
8588
const mainPkgName = getPkgFolder(packageName);
8689

8790
const mainPkgPath = path.join(currentPath, 'node_modules', mainPkgName);

0 commit comments

Comments
 (0)