do not load json configs via require for prevent caching

This commit is contained in:
oleg 2015-06-14 16:56:52 +03:00
parent 92a8631cd3
commit 944a98947c
2 changed files with 15 additions and 5 deletions

2
app.js
View File

@ -105,7 +105,7 @@ Steppy(
project.load(baseDir, projectName, function(err, project) {
if (err) {
return console.error(
'Error during load project "' + projectName + '": ' +
'Error during load project "' + projectName + '": ',
err.stack || err
);
}

View File

@ -1,8 +1,10 @@
'use strict';
var inherits = require('util').inherits,
var Steppy = require('twostep').Steppy,
inherits = require('util').inherits,
ParentReader = require('./base').Reader,
path = require('path');
path = require('path'),
fs = require('fs');
function Reader() {
@ -16,6 +18,14 @@ exports.Reader = Reader;
Reader.prototype.ext = 'json';
Reader.prototype._load = function(dir, name, callback) {
var content = require(path.join(dir, name + '.' + this.ext));
callback(null, content);
var self = this;
Steppy(
function() {
fs.readFile(path.join(dir, name + '.' + self.ext), 'utf8', this.slot())
},
function(err, content) {
this.pass(JSON.parse(content));
},
callback
);
};