Skip to content

Commit

Permalink
Handle file downloads asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed May 14, 2018
1 parent 8c78c0c commit 3b9dcbf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/utils.js
Expand Up @@ -139,7 +139,11 @@ exports.toMMMYY = date => {
}

exports.downloadToFile = (url, dest) => {
download(url).pipe(fs.createWriteStream(dest))
download(url).then(data => {
fs.writeFileSync(dest, data);
}).catch(err => {
console.error('Failed to download ' + url + ' (' + err.statusMessage + ')')
})
}

exports.jwtFrom = ({headers}) => {
Expand Down

0 comments on commit 3b9dcbf

Please sign in to comment.