mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-18 17:00:25 +00:00
Switch to using the Promise constructor rather than deferred, it allows for slightly nicer code. Also add some parens in appropriate places.
This commit is contained in:
parent
4d5c18ec6f
commit
b3f9f9b1ef
@ -37,18 +37,14 @@ exports.start = start = (app) ->
|
|||||||
console.log("Pulling image:", app.imageId)
|
console.log("Pulling image:", app.imageId)
|
||||||
docker.createImageAsync(fromImage: app.imageId)
|
docker.createImageAsync(fromImage: app.imageId)
|
||||||
.then (stream) ->
|
.then (stream) ->
|
||||||
deferred = Promise.defer()
|
return new Promise (resolve, reject) ->
|
||||||
|
if stream.headers['content-type'] is 'application/json'
|
||||||
|
stream.pipe(JSONStream.parse('error'))
|
||||||
|
.pipe(es.mapSync(reject))
|
||||||
|
else
|
||||||
|
stream.pipe(es.wait((error, text) -> reject(text))
|
||||||
|
|
||||||
if stream.headers['content-type'] is 'application/json'
|
stream.on('end', resolve)
|
||||||
stream.pipe(JSONStream.parse('error'))
|
|
||||||
.pipe es.mapSync (error) ->
|
|
||||||
deferred.reject(error)
|
|
||||||
else
|
|
||||||
stream.pipe es.wait (error, text) -> deferred.reject(text)
|
|
||||||
|
|
||||||
stream.on 'end', -> deferred.resolve()
|
|
||||||
|
|
||||||
return deferred.promise
|
|
||||||
.then ->
|
.then ->
|
||||||
console.log("Creating container:", app.imageId)
|
console.log("Creating container:", app.imageId)
|
||||||
ports = {}
|
ports = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user