Update the euristic for getting the NPM workspace root.
This commit is contained in:
@ -14,6 +14,8 @@ export function getNpmWorkspaceRootDirPath(params: {
|
||||
pathJoin(...[reactAppRootDirPath, ...Array(depth).fill("..")])
|
||||
);
|
||||
|
||||
assert(cwd !== pathSep, "NPM workspace not found");
|
||||
|
||||
try {
|
||||
child_process.execSync("npm config get", {
|
||||
cwd,
|
||||
@ -21,17 +23,18 @@ export function getNpmWorkspaceRootDirPath(params: {
|
||||
});
|
||||
} catch (error) {
|
||||
if (String(error).includes("ENOWORKSPACES")) {
|
||||
assert(cwd !== pathSep, "NPM workspace not found");
|
||||
|
||||
return callee(depth + 1);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
const { isExpectedDependencyFound } = (() => {
|
||||
const packageJsonFilePath = pathJoin(cwd, "package.json");
|
||||
|
||||
if (!fs.existsSync(packageJsonFilePath)) {
|
||||
return callee(depth + 1);
|
||||
}
|
||||
|
||||
assert(fs.existsSync(packageJsonFilePath));
|
||||
|
||||
const parsedPackageJson = JSON.parse(
|
||||
@ -59,10 +62,7 @@ export function getNpmWorkspaceRootDirPath(params: {
|
||||
isExpectedDependencyFound = true;
|
||||
}
|
||||
|
||||
return { isExpectedDependencyFound };
|
||||
})();
|
||||
|
||||
if (!isExpectedDependencyFound) {
|
||||
if (!isExpectedDependencyFound && parsedPackageJson.name !== dependencyExpected) {
|
||||
return callee(depth + 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user