Skip to content

Commit

Permalink
fix(@angular/cli): Improve error message for create component with -m…
Browse files Browse the repository at this point in the history
… option
  • Loading branch information
wKoza authored and hansl committed May 3, 2017
1 parent 806447e commit b11d560
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/@angular/cli/blueprints/component/index.ts
Expand Up @@ -231,7 +231,17 @@ export default Blueprint.extend({
path.relative(this.project.root, this.pathToModule));
return;
}
const preChange = fs.readFileSync(this.pathToModule, 'utf8');

let preChange: any;
try {
preChange = fs.readFileSync(this.pathToModule, 'utf8');
} catch (err) {
if (err.code === 'EISDIR') {
throw 'Module specified should be a file, not a directory';
} else {
throw err;
}
}

returns.push(
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
Expand Down

0 comments on commit b11d560

Please sign in to comment.