fix(misc): workspaces using nx wrapper do not contain a package.json, so don't read the scope from it

This commit is contained in:
AgentEnder 2023-05-16 17:31:05 -04:00 committed by Victor Savkin
parent be267a7cd9
commit ae6e90c86d
2 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,9 @@ export function getNpmScope(tree: Tree): string | undefined {
return nxJson.npmScope;
}
const { name } = readJson<{ name?: string }>(tree, 'package.json');
const { name } = tree.exists('package.json')
? readJson<{ name?: string }>(tree, 'package.json')
: { name: null };
if (name?.startsWith('@')) {
return name.split('/')[0].substring(1);

View File

@ -17,7 +17,9 @@ function getNpmScope(tree: Tree) {
return nxJson.npmScope;
}
const { name } = readJson<{ name?: string }>(tree, 'package.json');
const { name } = tree.exists('package.json')
? readJson<{ name?: string }>(tree, 'package.json')
: { name: null };
if (name?.startsWith('@')) {
return name.split('/')[0].substring(1);