Skip to content

Commit b11d560

Browse files
wKozahansl
authored andcommitted
fix(@angular/cli): Improve error message for create component with -m option
1 parent 806447e commit b11d560

File tree

1 file changed

+11
-1
lines changed
  • packages/@angular/cli/blueprints/component

1 file changed

+11
-1
lines changed

packages/@angular/cli/blueprints/component/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,17 @@ export default Blueprint.extend({
231231
path.relative(this.project.root, this.pathToModule));
232232
return;
233233
}
234-
const preChange = fs.readFileSync(this.pathToModule, 'utf8');
234+
235+
let preChange: any;
236+
try {
237+
preChange = fs.readFileSync(this.pathToModule, 'utf8');
238+
} catch (err) {
239+
if (err.code === 'EISDIR') {
240+
throw 'Module specified should be a file, not a directory';
241+
} else {
242+
throw err;
243+
}
244+
}
235245

236246
returns.push(
237247
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)

0 commit comments

Comments
 (0)