3 var _ = require('lodash'),
4 fs = require('fs-extra'),
5 glob = require('glob'),
6 path = require('path');
8 var minify = require('../common/minify.js');
10 /*----------------------------------------------------------------------------*/
13 * Creates a [fs.copy](https://github.com/jprichardson/node-fs-extra#copy)
14 * function with `srcPath` and `destPath` partially applied.
17 * @param {string} srcPath The path of the file to copy.
18 * @param {string} destPath The path to copy the file to.
19 * @returns {Function} Returns the partially applied function.
21 function copy(srcPath, destPath) {
22 return _.partial(fs.copy, srcPath, destPath);
26 * Creates an object of compiled template and base name pairs that match `pattern`.
29 * @param {string} pattern The glob pattern to be match.
30 * @returns {Object} Returns the object of compiled templates.
32 function globTemplate(pattern) {
33 return _.transform(glob.sync(pattern), function(result, filePath) {
34 var key = path.basename(filePath, path.extname(filePath));
35 result[key] = _.template(fs.readFileSync(filePath, 'utf8'));
40 * Creates a `minify` function with `srcPath` and `destPath` partially applied.
43 * @param {string} srcPath The path of the file to minify.
44 * @param {string} destPath The path to write the file to.
45 * @returns {Function} Returns the partially applied function.
47 function min(srcPath, destPath) {
48 return _.partial(minify, srcPath, destPath);
52 * Creates a [fs.writeFile](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
53 * function with `filePath` and `data` partially applied.
56 * @param {string} destPath The path to write the file to.
57 * @param {string} data The data to write to the file.
58 * @returns {Function} Returns the partially applied function.
60 function write(destPath, data) {
61 return _.partial(fs.writeFile, destPath, data);
64 /*----------------------------------------------------------------------------*/
68 'globTemplate': globTemplate,