fix(bazel): make name param in ng add optional (#30074)

PR Close #30074
This commit is contained in:
Keen Yee Liau
2019-04-23 14:52:26 -07:00
committed by Andrew Kushnir
parent 2905bf5548
commit 0b5f480eca
4 changed files with 17 additions and 4 deletions

View File

@ -11,7 +11,7 @@
import {JsonAstObject, parseJsonAst} from '@angular-devkit/core';
import {Rule, SchematicContext, SchematicsException, Tree, apply, applyTemplates, chain, mergeWith, url} from '@angular-devkit/schematics';
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
import {getWorkspacePath} from '@schematics/angular/utility/config';
import {getWorkspace, getWorkspacePath} from '@schematics/angular/utility/config';
import {findPropertyInAstObject, insertPropertyInAstObjectInOrder} from '@schematics/angular/utility/json-utils';
import {validateProjectName} from '@schematics/angular/utility/validation';
@ -118,7 +118,7 @@ function updateGitignore() {
*/
function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
return (host: Tree, context: SchematicContext) => {
const {name} = options;
const name = options.name !;
const workspacePath = getWorkspacePath(host);
if (!workspacePath) {
throw new Error('Could not find angular.json');
@ -374,6 +374,10 @@ function installNodeModules(options: Schema): Rule {
export default function(options: Schema): Rule {
return (host: Tree) => {
options.name = options.name || getWorkspace(host).defaultProject;
if (!options.name) {
throw new Error('Please specify a project using "--name project-name"');
}
validateProjectName(options.name);
return chain([