File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -342,12 +342,13 @@ Builder.prototype.append = function(str){
342
342
Builder . prototype . json = function ( fn ) {
343
343
var self = this ;
344
344
var cache = this . _cache ;
345
-
345
+
346
+ // conf has already been validated
346
347
if ( this . conf ) return fn ( null , this . conf ) ;
347
348
348
349
var path = this . path ( 'component.json' ) ;
349
350
var conf = cache [ path ] ;
350
- if ( conf ) return fn ( null , this . conf = conf ) ;
351
+ if ( conf ) return validate ( this . conf ) ;
351
352
352
353
debug ( 'reading %s' , path ) ;
353
354
fs . readFile ( path , 'utf8' , function ( err , str ) {
@@ -359,11 +360,17 @@ Builder.prototype.json = function(fn){
359
360
self . _emittedConfig = true ;
360
361
self . emit ( 'config' ) ;
361
362
}
362
- fn ( null , self . conf ) ;
363
+ validate ( self . conf ) ;
363
364
} catch ( err ) {
364
365
fn ( err ) ;
365
366
}
366
367
} ) ;
368
+
369
+ function validate ( conf ) {
370
+ if ( ! conf . name ) return fn ( new Error ( path + " attribute \"name\" missing" ) ) ;
371
+ self . conf = conf ;
372
+ fn ( null , conf ) ;
373
+ }
367
374
} ;
368
375
369
376
/**
You can’t perform that action at this time.
0 commit comments