I am trying to run a task in grunt, it goes to a URL and saves the response in a file, but I want it to go to different URLs and make different files accordingly. So I am running a loop and at every iteration changing the data in config. But the task runs are appended at the end of the loop, so when loop is done changing all the values in config it runs the task 30 times with the latest changed values in the config, finally creating only 1 file 30 times again and again. Here is my code
module.exports = function(grunt){
grunt.initConfig({
id:0,
http:{
devel:{
options: {
url: 'http://127.0.0.1:8000/foo/<%= id %>/'
},
dest: 'www/foos/foo<%= id %>.json'
}
}
});
grunt.loadNpmTasks('grunt-http');
grunt.registerTask("default", function(){
for (var i = 30; i > 1; i--) {
grunt.config.set("id", i);
var d = grunt.config.get("id");
grunt.log.writeln("id = "+d);
grunt.task.run("http");
}
});
};