JsonFiles has errors

This commit is contained in:
Fede Ramirez
2015-03-26 23:08:35 -03:00
parent 27b9934080
commit c5327a20fc
2 changed files with 9 additions and 4 deletions
+4 -4
View File
@@ -39,11 +39,12 @@ program
*/
var error = function(msg){
if(!program.onlyErrors)
log.error(msg);
if(Array.isArray(msg)) {
error.summary.concat(msg);
error.summary = error.summary.concat(msg);
} else {
error.summary.push(msg);
@@ -80,7 +81,7 @@ var ok = function(msg){
*/
var overrideFile = new OverrideFile();
if(overrideFile.errors().length) {
if(overrideFile.hasErrors()) {
// json format errors
error(overrideFile.errors());
@@ -138,7 +139,7 @@ forOwn(endpoints, function(Endpoint, endpointName){
return;
var overrideFile = new JsonFile(fileinfo.path);
if(overrideFile.errors().length)
if(overrideFile.hasErrors())
return error( util.format('%s is not valid json file \n - %s', gray(fileinfo.path), overrideFile.errors().join('\n -')) );
ok( fileinfo.canonicalPackageName + '@' + fileinfo.packageVersion );
@@ -150,7 +151,6 @@ forOwn(endpoints, function(Endpoint, endpointName){
//
// SUMMARY LOG
//
if(error.summary.length) {
log.n()
('Error summary ................')
+5
View File
@@ -44,6 +44,11 @@ JsonFile.prototype.errors = function(){
return this._errors;
};
JsonFile.prototype.hasErrors = function(){
return this._errors.length > 0;
};
JsonFile.prototype.forEach = function(fn){
forOwn(this._json, fn, this);