Create folder if it doesn't exist when downloading files

This commit is contained in:
Antonio Scandurra 2016-08-13 10:43:32 +02:00
parent de7e6c977f
commit df6e0aca1b
2 changed files with 4 additions and 1 deletions

View File

@ -49,7 +49,6 @@ prebuildLessCache()
generateMetadata()
generateAPIDocs()
downloadChromedriver()
dumpSymbols()
.then(packageApplication)
.then(packagedAppPath => {

View File

@ -1,4 +1,7 @@
'use strict'
const fs = require('fs-extra')
const path = require('path')
const syncRequest = require('sync-request')
module.exports = function (downloadURL, destinationPath) {
@ -8,6 +11,7 @@ module.exports = function (downloadURL, destinationPath) {
})
if (response.statusCode === 200) {
fs.mkdirpSync(path.dirname(destinationPath))
fs.writeFileSync(destinationPath, response.body)
} else {
throw new Error('Error downloading file. HTTP Status ' + response.statusCode + '.')