title: how to run a grunt task in a for loop while dynamically changing the data in config?
body: <p>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
  <div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>module.exports = function(grunt){
   grunt.initConfig({
    id:0,
    http:{
     devel:{
     options: {
       url: 'http://127.0.0.1:8000/foo/&lt;%= id %&gt;/'
     },
     dest: 'www/foos/foo&lt;%= id %&gt;.json'
     }
    }
   });
   grunt.loadNpmTasks('grunt-http');   
   grunt.registerTask("default", function(){
      for (var i = 30; i &gt; 1; i--) {
        grunt.config.set("id", i);
        var d = grunt.config.get("id");
        grunt.log.writeln("id = "+d);
        grunt.task.run("http");
      }
    });
  };</code></pre>
  </div>
  </div>
  </p>