Skip to content

Instantly share code, notes, and snippets.

@alebianco
Last active May 5, 2016 15:56
Show Gist options
  • Save alebianco/85500551f92bcc578a3328f013c1833a to your computer and use it in GitHub Desktop.
Save alebianco/85500551f92bcc578a3328f013c1833a to your computer and use it in GitHub Desktop.
grunt-run-task issue #9
module.exports = function (grunt) {
grunt.initConfig({});
grunt.registerTask('test', 'testing grunt-run-task', function() {
var runTask = require('grunt-run-task');
runTask.loadNpmTasks("grunt-fileindex");
function createConfig(folder) {
return {
resources: {
options: {
format: 'json_flat',
pretty: true
},
files: [{
src: '**/*.*',
dest: folder + '/resources.json'
}]
}
};
}
function createTask(config) {
console.log("create task");
var task = runTask.task('fileindex', config);
return task;
}
function executeTask(task) {
console.log("running task");
task.run("resources", function (error, task) {
if (error) {
console.error(error);
}
console.log("task complete");
});
}
// expected: should exectute "fileindex:resources" 5 times
// actual: tries to execute "fileindex:resources:resources" and doesn't even throw an error
var folders = ["one", "two", "three", "four", "five"];
folders.map(createConfig).map(createTask).forEach(executeTask);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment