'use strict';
-var _ = require('lodash'),
- fs = require('fs-extra'),
- glob = require('glob'),
- path = require('path');
-
-var minify = require('../common/minify.js');
+var _ = require('lodash');
/*----------------------------------------------------------------------------*/
-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));
- result[key] = _.template(fs.readFileSync(filePath, 'utf8'));
- }, {});
+/**
+ * Creates a hash object. If a `properties` object is provided, its own
+ * enumerable properties are assigned to the created object.
+ *
+ * @memberOf util
+ * @param {Object} [properties] The properties to assign to the object.
+ * @returns {Object} Returns the new hash object.
+ */
+function Hash(properties) {
+ return _.transform(properties, function(result, value, key) {
+ result[key] = (_.isPlainObject(value) && !(value instanceof Hash))
+ ? new Hash(value)
+ : value;
+ }, this);
}
-function minFile(srcPath, destPath) {
- return _.partial(minify, srcPath, destPath);
-}
-
-function writeFile(filePath, data) {
- return _.partial(fs.writeFile, filePath, data);
-}
+Hash.prototype = Object.create(null);
module.exports = {
- 'copyFile': copyFile,
- 'globTemplate': globTemplate,
- 'minFile': minFile,
- 'writeFile': writeFile
+ 'Hash': Hash
};