Skip to content

Commit

Permalink
fix(misc): workspaces using nx wrapper do not contain a package.json,…
Browse files Browse the repository at this point in the history
… so don't read the scope from it
  • Loading branch information
AgentEnder authored and vsavkin committed May 17, 2023
1 parent be267a7 commit ae6e90c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/js/src/utils/package-json/get-npm-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion packages/workspace/src/utilities/get-import-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

1 comment on commit ae6e90c

@vercel
Copy link

@vercel vercel bot commented on ae6e90c May 17, 2023

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-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.