Browse Source

use getWorkspaceSchema instead of JSON.parse

pull/8101/head
Arman Ozak 5 years ago
parent
commit
dfa96501db
  1. 7
      npm/ng-packs/packages/schematics/src/utils/workspace.ts

7
npm/ng-packs/packages/schematics/src/utils/workspace.ts

@ -2,7 +2,7 @@ import { strings, workspaces } from '@angular-devkit/core';
import { SchematicsException, Tree } from '@angular-devkit/schematics';
import { Exception } from '../enums';
import { Project } from '../models';
import { getWorkspace, ProjectType, WorkspaceSchema } from './angular';
import { getWorkspace, getWorkspaceSchema, ProjectType, WorkspaceSchema } from './angular';
import { findEnvironmentExpression } from './ast';
import { readFileInTree } from './common';
@ -20,13 +20,12 @@ export function readEnvironment(tree: Tree, project: workspaces.ProjectDefinitio
}
export function readWorkspaceSchema(tree: Tree) {
const workspaceBuffer = tree.read('/angular.json') || tree.read('/workspace.json');
if (!workspaceBuffer) throw new SchematicsException(Exception.NoWorkspace);
if (!tree.exists('/angular.json')) throw new SchematicsException(Exception.NoWorkspace);
let workspaceSchema: WorkspaceSchema;
try {
workspaceSchema = JSON.parse(workspaceBuffer.toString());
workspaceSchema = getWorkspaceSchema(tree);
} catch (_) {
throw new SchematicsException(Exception.InvalidWorkspace);
}

Loading…
Cancel
Save