nci/lib/reader/json.js

32 lines
587 B
JavaScript
Raw Normal View History

2015-05-18 17:52:01 +00:00
'use strict';
var Steppy = require('twostep').Steppy,
inherits = require('util').inherits,
2015-05-18 17:52:01 +00:00
ParentReader = require('./base').Reader,
path = require('path'),
fs = require('fs');
2015-05-18 17:52:01 +00:00
function Reader() {
ParentReader.call(this);
}
inherits(Reader, ParentReader);
exports.Reader = Reader;
Reader.prototype.ext = 'json';
Reader.prototype._load = function(dir, name, callback) {
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
);
2015-05-18 17:52:01 +00:00
};