Add lib/common/util.

This commit is contained in:
John-David Dalton
2016-02-14 12:57:34 -08:00
parent d358d00531
commit c006c28f55
2 changed files with 45 additions and 20 deletions

18
lib/common/util.js Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var _ = require('lodash'),
fs = require('fs-extra'),
glob = require('glob'),
path = require('path');
/*----------------------------------------------------------------------------*/
function globTemplate(pattern) {
return _.transform(glob.sync(pattern), function(result, filePath) {
result[path.basename(filePath, path.extname(filePath))] = _.template(fs.readFileSync(filePath));
}, {});
}
module.exports = {
'globTemplate': globTemplate
};