Skip to content

Commit c69981f

Browse files
clydinhansl
authored andcommitted
fix(@angular/cli): ensure all architect schema errors are propagated
1 parent cddb836 commit c69981f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/angular/cli/models/architect-command.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
166166
if (!targetSpec.project && this.target) {
167167
// This runs each target sequentially.
168168
// Running them in parallel would jumble the log messages.
169-
return from(this.getProjectNamesByTarget(this.target)).pipe(
169+
return await from(this.getProjectNamesByTarget(this.target)).pipe(
170170
concatMap(project => runSingleTarget({ ...targetSpec, project })),
171171
toArray(),
172172
).toPromise().then(results => results.every(res => res === 0) ? 0 : 1);
173173
} else {
174-
return runSingleTarget(targetSpec).toPromise();
174+
return await runSingleTarget(targetSpec).toPromise();
175175
}
176176
} catch (e) {
177177
if (e instanceof schema.SchemaValidationException) {
@@ -182,8 +182,6 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
182182
if (unknownProperty in options) {
183183
const dashes = unknownProperty.length === 1 ? '-' : '--';
184184
this.logger.fatal(`Unknown option: '${dashes}${unknownProperty}'`);
185-
186-
break;
187185
}
188186
}
189187
newErrors.push(schemaError);
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { ng } from '../../utils/process';
1+
import { execAndWaitForOutputToMatch, ng } from '../../utils/process';
2+
import { expectToFail } from '../../utils/utils';
23

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

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

0 commit comments

Comments
 (0)