Skip to content

Commit

Permalink
fix(@angular/cli): do not show stack on argument parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Sep 19, 2018
1 parent f7f5b28 commit 97576ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions packages/angular/cli/models/command-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,20 @@ export async function runCommand(
return 1;
}

const parsedOptions = parser.parseArguments(args, description.options);
Command.setCommandMap(commandMap);
const command = new description.impl({ workspace }, description, logger);

return await command.validateAndRun(parsedOptions);
try {
const parsedOptions = parser.parseArguments(args, description.options);
Command.setCommandMap(commandMap);
const command = new description.impl({ workspace }, description, logger);

return await command.validateAndRun(parsedOptions);
} catch (e) {
if (e instanceof parser.ParseArgumentException) {
logger.fatal('Cannot parse arguments. See below for the reasons.');
logger.fatal(' ' + e.comments.join('\n '));

return 1;
} else {
throw e;
}
}
}
2 changes: 1 addition & 1 deletion packages/angular/cli/models/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Arguments, Option, OptionType, Value } from './interface';

export class ParseArgumentException extends BaseException {
constructor(
comments: string[],
public readonly comments: string[],
public readonly parsed: Arguments,
public readonly ignored: string[],
) {
Expand Down

0 comments on commit 97576ec

Please sign in to comment.