fix(core): detect angular cli workspace correctly (#13574)
This commit is contained in:
parent
2eb8650df8
commit
59a7af2c98
@ -1,5 +1,3 @@
|
|||||||
import { existsSync } from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import { workspaceRootInner } from './workspace-root';
|
import { workspaceRootInner } from './workspace-root';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,7 +11,7 @@ export function findWorkspaceRoot(dir: string): WorkspaceTypeAndRoot | null {
|
|||||||
|
|
||||||
if (r === null) return null;
|
if (r === null) return null;
|
||||||
|
|
||||||
if (existsSync(path.join(r, 'angular.json'))) {
|
if (isAngularCliInstalled(r)) {
|
||||||
return { type: 'angular', dir: r };
|
return { type: 'angular', dir: r };
|
||||||
} else {
|
} else {
|
||||||
return { type: 'nx', dir: r };
|
return { type: 'nx', dir: r };
|
||||||
@ -24,3 +22,14 @@ export interface WorkspaceTypeAndRoot {
|
|||||||
type: 'nx' | 'angular';
|
type: 'nx' | 'angular';
|
||||||
dir: string;
|
dir: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAngularCliInstalled(root: string): boolean {
|
||||||
|
try {
|
||||||
|
require.resolve('@angular/cli', {
|
||||||
|
paths: [root],
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user