refactoring the testing process
This commit is contained in:
@@ -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){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user