Skip to content

Commit

Permalink
fix(@angular/cli): exit with error code if unknown option is present
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and hansl committed Jun 6, 2018
1 parent c8e7313 commit b5d9ac6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,17 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
if (unknownProperty in options) {
const dashes = unknownProperty.length === 1 ? '-' : '--';
this.logger.fatal(`Unknown option: '${dashes}${unknownProperty}'`);
continue;
}
}
newErrors.push(schemaError);
}

if (newErrors.length > 0) {
this.logger.error(new schema.SchemaValidationException(newErrors).message);

return 1;
}

return 0;
return 1;
} else {
throw e;
}
Expand Down
8 changes: 7 additions & 1 deletion tests/legacy-cli/e2e/tests/commands/unknown-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import { execAndWaitForOutputToMatch, ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';

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

await execAndWaitForOutputToMatch(
'ng',
[ 'build', '--notanoption' ],
/Unknown option: '--notanoption'/,
);

await expectToFail(() => execAndWaitForOutputToMatch(
'ng',
[ 'build', '--notanoption' ],
/should NOT have additional properties\(notanoption\)./,
));
}

0 comments on commit b5d9ac6

Please sign in to comment.