Skip to content

Commit

Permalink
fix(@angular/cli): ensure all architect schema errors are propagated
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and hansl committed Jun 6, 2018
1 parent cddb836 commit c69981f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 2 additions & 4 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
if (!targetSpec.project && this.target) {
// This runs each target sequentially.
// Running them in parallel would jumble the log messages.
return from(this.getProjectNamesByTarget(this.target)).pipe(
return await from(this.getProjectNamesByTarget(this.target)).pipe(
concatMap(project => runSingleTarget({ ...targetSpec, project })),
toArray(),
).toPromise().then(results => results.every(res => res === 0) ? 0 : 1);
} else {
return runSingleTarget(targetSpec).toPromise();
return await runSingleTarget(targetSpec).toPromise();
}
} catch (e) {
if (e instanceof schema.SchemaValidationException) {
Expand All @@ -182,8 +182,6 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
if (unknownProperty in options) {
const dashes = unknownProperty.length === 1 ? '-' : '--';
this.logger.fatal(`Unknown option: '${dashes}${unknownProperty}'`);

break;
}
}
newErrors.push(schemaError);
Expand Down
13 changes: 8 additions & 5 deletions tests/legacy-cli/e2e/tests/commands/unknown-option.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ng } from '../../utils/process';
import { execAndWaitForOutputToMatch, ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';

export default async function() {
const { stderr } = await ng('build', '--notanoption');
// await expectToFail(() => ng('build', '--notanoption'));

if (!stderr.match(/Unknown option: '--notanoption'/)) {
throw new Error(`Expected "Unknown option:", received "${JSON.stringify(stderr)}".`);
}
await execAndWaitForOutputToMatch(
'ng',
[ 'build', '--notanoption' ],
/Unknown option: '--notanoption'/,
);
}

0 comments on commit c69981f

Please sign in to comment.