refactoring the testing process

This commit is contained in:
Fede Ramirez
2015-03-23 05:15:10 -03:00
parent b825142f83
commit d9d4471678
5 changed files with 219 additions and 134 deletions
+7 -8
View File
@@ -1,5 +1,5 @@
"use strict;"
var fs = require('fs');
'use strict';
var mout = require('mout');
var extend = mout.object.deepMixIn;
var forOwn = mout.object.forOwn;
@@ -14,19 +14,18 @@ var JsonFile = module.exports = function JsonFile(file){
return new JsonFile(file);
this._file = String(file);
this._errors = this._errors || [];
this._json = this._json || {};
this._errors = [];
this._json = {};
if( !(/\.json$/.test(file)) ){
this.error(this._file + ' is not json file');
} else {
try{
try {
extend(this._json, require(this._file));
} catch(e) {
this.error(e.message);
}
@@ -38,12 +37,12 @@ JsonFile.prototype.error = function(msg){
this._errors.push(msg);
return this;
}
};
JsonFile.prototype.errors = function(){
return this._errors;
}
};
JsonFile.prototype.forEach = function(fn){