Skip to content

Instantly share code, notes, and snippets.



Last active Jan 3, 2016
What would you like to do?
Copy component.json to a work folder, parse and then nuke the work folder. I did this because `grunt.file.expand` was too slow on my project structure, especially with all the node_modules folders present under multiple sub-projects.
module.exports = function (grunt) {
'use strict';
grunt.renameTask('clean', 'nuke');
nuke: {
work: ['work']
shell: {
warmup: {
options: {
stdout: true
command: 'for config in `find . -name component.json -maxdepth 2 -not -path \'./bootstrap/*\' -not -path \'./work/*\'`; do (parent=`dirname $config` && mkdir -p work/$parent && cp $config work/$parent/); done'
grunt.registerTask('cook', 'Generate the moduleMap', function () {
var map = {},
features = grunt.file.expand({
filter: 'isFile'
}, [
features.forEach(function (feature) {
var config = require(feature);
map[] = {
version: config.version
grunt.file.write('bootstrap/lib/moduleMap.js', 'module.exports=' + JSON.stringify(map));
grunt.registerTask('warmup', [
$ grunt warmup
Running "shell:warmup" (shell) task
Running "cook" task
Running "nuke:work" (nuke) task
Cleaning work...OK
Done, without errors.
Elapsed time
loading tasks 156ms
shell:warmup 170ms
nuke:work 29ms
Total 355ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment