Skip to content

Commit b5d9ac6

Browse files
clydinhansl
authored andcommitted
fix(@angular/cli): exit with error code if unknown option is present
1 parent c8e7313 commit b5d9ac6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,17 @@ 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+
continue;
185186
}
186187
}
187188
newErrors.push(schemaError);
188189
}
189190

190191
if (newErrors.length > 0) {
191192
this.logger.error(new schema.SchemaValidationException(newErrors).message);
192-
193-
return 1;
194193
}
195194

196-
return 0;
195+
return 1;
197196
} else {
198197
throw e;
199198
}

tests/legacy-cli/e2e/tests/commands/unknown-option.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import { execAndWaitForOutputToMatch, ng } from '../../utils/process';
22
import { expectToFail } from '../../utils/utils';
33

44
export default async function() {
5-
// await expectToFail(() => ng('build', '--notanoption'));
5+
await expectToFail(() => ng('build', '--notanoption'));
66

77
await execAndWaitForOutputToMatch(
88
'ng',
99
[ 'build', '--notanoption' ],
1010
/Unknown option: '--notanoption'/,
1111
);
12+
13+
await expectToFail(() => execAndWaitForOutputToMatch(
14+
'ng',
15+
[ 'build', '--notanoption' ],
16+
/should NOT have additional properties\(notanoption\)./,
17+
));
1218
}

0 commit comments

Comments
 (0)