Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 0728668

Browse files
author
Markus Falk
committed
[FEATURE] add meaningfull error messages to subgens refs #165
1 parent 135b3f9 commit 0728668

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

addcomponent/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,9 @@ AddcomponentGenerator = yeoman.generators.NamedBase.extend({
250250
path = 'components/_' + this.pkg.name + '.scss';
251251
}
252252

253-
this.log('PATH: ' + path);
254-
253+
// exit app when file doesn't exist
255254
if(!this.fs.exists(path)) {
256-
this.log.error('FILE DOESNT EXIST');
255+
this.emit('error', 'Does ' + path + ' exist?');
257256
}
258257

259258
// read
@@ -291,8 +290,14 @@ AddcomponentGenerator = yeoman.generators.NamedBase.extend({
291290
if (this.includeJS) {
292291

293292
var
294-
path = 'components/' + this.pkg.name + '.js',
295-
file = this.fs.read(path),
293+
path = 'components/' + this.pkg.name + '.js';
294+
295+
// exit app when file doesn't exist
296+
if(!this.fs.exists(path)) {
297+
this.emit('error', 'Does ' + path + ' exist?');
298+
}
299+
300+
var file = this.fs.read(path),
296301
match = '//{{app}}',
297302
regex = new RegExp('/' + string.slugify(this.name) + '/', 'g'),
298303
line = lineNumber(file, regex),

removecomponent/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ RemovecomponentGenerator = yeoman.generators.NamedBase.extend({
144144
path = 'components/_' + this.pkg.name + '.scss';
145145
}
146146

147+
// exit app when file doesn't exist
148+
if(!this.fs.exists(path)) {
149+
this.emit('error', 'Does ' + path + ' exist?');
150+
}
151+
147152
var file = this.fs.read(path);
148153

149154
if (this.ComponentType === 'standardModule') {
@@ -165,7 +170,14 @@ RemovecomponentGenerator = yeoman.generators.NamedBase.extend({
165170
removeFromRequireJS: function () {
166171

167172
var
168-
path = 'components/' + this.pkg.name + '.js',
173+
path = 'components/' + this.pkg.name + '.js';
174+
175+
// exit app when file doesn't exist
176+
if(!this.fs.exists(path)) {
177+
this.emit('error', 'Does ' + path + ' exist?');
178+
}
179+
180+
var
169181
file = this.fs.read(path),
170182
newcontent = '',
171183
match;

0 commit comments

Comments
 (0)