Skip to content

Commit

Permalink
fix(core): detect angular cli workspace correctly (#13574)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Dec 2, 2022
1 parent 2eb8650 commit 59a7af2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/nx/src/utils/find-workspace-root.ts
@@ -1,5 +1,3 @@
import { existsSync } from 'fs';
import * as path from 'path';
import { workspaceRootInner } from './workspace-root';

/**
Expand All @@ -13,7 +11,7 @@ export function findWorkspaceRoot(dir: string): WorkspaceTypeAndRoot | null {

if (r === null) return null;

if (existsSync(path.join(r, 'angular.json'))) {
if (isAngularCliInstalled(r)) {
return { type: 'angular', dir: r };
} else {
return { type: 'nx', dir: r };
Expand All @@ -24,3 +22,14 @@ export interface WorkspaceTypeAndRoot {
type: 'nx' | 'angular';
dir: string;
}

function isAngularCliInstalled(root: string): boolean {
try {
require.resolve('@angular/cli', {
paths: [root],
});
return true;
} catch {
return false;
}
}

1 comment on commit 59a7af2

@vercel
Copy link

@vercel vercel bot commented on 59a7af2 Dec 2, 2022

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

Please sign in to comment.