Add copyFile, minFile, and writeFile to lib/common/util.js.

This commit is contained in:
John-David Dalton
2016-02-21 18:36:12 -08:00
parent 1517745a6a
commit f2985bda5f
5 changed files with 40 additions and 32 deletions

View File

@@ -5,8 +5,14 @@ var _ = require('lodash'),
glob = require('glob'),
path = require('path');
var minify = require('../common/minify.js');
/*----------------------------------------------------------------------------*/
function copyFile(srcPath, destPath) {
return _.partial(fs.copy, srcPath, destPath);
}
function globTemplate(pattern) {
return _.transform(glob.sync(pattern), function(result, filePath) {
var key = path.basename(filePath, path.extname(filePath));
@@ -14,6 +20,17 @@ function globTemplate(pattern) {
}, {});
}
function minFile(srcPath, destPath) {
return _.partial(minify, srcPath, destPath);
}
function writeFile(filePath, data) {
return _.partial(fs.writeFile, filePath, data);
}
module.exports = {
'globTemplate': globTemplate
'copyFile': copyFile,
'globTemplate': globTemplate,
'minFile': minFile,
'writeFile': writeFile
};