Created
July 25, 2014 08:03
-
-
Save mach3/faf2e3720fdcf6e7c8e3 to your computer and use it in GitHub Desktop.
grunt-resolve-json.js: Load map.json and resolve paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt){ | |
var path = require("path"), | |
_ = grunt.util._; | |
/** | |
* Resolve dest and src files' path | |
* @param {String} file | |
* @returns {Object} | |
*/ | |
grunt.resolveJSON = function(file){ | |
var dir, data, files = {}; | |
dir = path.dirname(file); | |
data = grunt.file.readJSON(file); | |
_.each(data, function(src, dest){ | |
files[path.join(dir, dest)] = src.map(function(name){ | |
return path.join(dir, name); | |
}); | |
}); | |
return files; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment