I am super new to Gulp so might be on the wrong track here but...
I am trying to create tasks dynamically from values in an object. A simple version of my code is:
var data = {"v1" : "foo",
"v2" : "bar",
"v3" : "foobar"};
var taskList = [];
for(var key in data){
taskList.push(key);
gulp.task(key, function(){
console.log(key, data[key]);
return;
});
}
gulp.task("master", taskList);
This creates and runs the three tasks as I expected but each one outputs v3 foobar
and the values foo
and bar
are unused.
I'm thinking this is maybe some kind of value vs reference issue and each task is receiving key
as a reference rather the actual value?
Can anyone shed any light?
Cheers all