From c5327a20fc5a668b17c50bc191a70559510498d9 Mon Sep 17 00:00:00 2001 From: Fede Ramirez Date: Thu, 26 Mar 2015 23:08:35 -0300 Subject: [PATCH] JsonFiles has errors --- test/index.js | 8 ++++---- test/lib/JsonFile.js | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/index.js b/test/index.js index ec06fd2..c2d0fd9 100644 --- a/test/index.js +++ b/test/index.js @@ -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 ................') diff --git a/test/lib/JsonFile.js b/test/lib/JsonFile.js index 165d563..b1d73b1 100644 --- a/test/lib/JsonFile.js +++ b/test/lib/JsonFile.js @@ -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);