balena-cli/lib/resin/models/os.coffee
2014-12-22 15:42:39 -04:00

16 lines
407 B
CoffeeScript

url = require('url')
fs = require('fs')
server = require('../_server/server')
settings = require('../settings')
exports.download = (parameters, destination, callback, onProgress) ->
query = url.format(query: parameters)
downloadUrl = url.resolve(settings.get('urls.download'), query)
server.request
method: 'GET'
url: downloadUrl
pipe: fs.createWriteStream(destination)
, callback
, onProgress