pure/index.js

20 lines
488 B
JavaScript
Raw Normal View History

2016-12-20 06:49:35 +00:00
var fs = require('fs');
var path = require('path');
var cache = {};
module.exports = {
getFile: function(name) {
if (!cache[name]) {
try {
cache[name] = fs.readFileSync(this.getFilePath(name), 'utf-8');
} catch(e) {
2024-10-07 17:40:18 +00:00
throw new Error(name + ' does not exist', e);
2016-12-20 06:49:35 +00:00
}
}
return cache[name];
},
getFilePath: function(name) {
return path.resolve(__dirname, 'build', name);
}
};