Skip to content

Instantly share code, notes, and snippets.

@mach3
Created July 25, 2014 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach3/faf2e3720fdcf6e7c8e3 to your computer and use it in GitHub Desktop.
Save mach3/faf2e3720fdcf6e7c8e3 to your computer and use it in GitHub Desktop.
grunt-resolve-json.js: Load map.json and resolve paths
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