I'm calling the download function below in a custom grunt task.
The dest
file gets created, but is always 0 bytes.
I've confirmed the files I'm grabbing are valid, and for the url, I am passing in the full protocol and path as it would appear in an address bar that shows the protocol.
I've had success with something similar before, so I'm wondering if perhaps it has something to do with running it in a grunt task.
Any ideas on why this function would only create an empty file?
var download = function(url, dest, cb) {
var file = fs.createWriteStream(dest);
http.get(url, function(response) {
response.pipe(file);
file.on('finish', function() {
file.close(cb);
console.log('complete');
});
});
};