Skip to content

Commit

Permalink
use promise api from avvio, upgrade avvio
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Aug 5, 2018
1 parent 76136eb commit 9a9fd1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
24 changes: 1 addition & 23 deletions packages/hemera/lib/index.js
Expand Up @@ -1554,20 +1554,6 @@ class Hemera extends EventEmitter {
* @memberof Hemera
*/
close(func) {
let promise

// callback style
if (func === undefined) {
promise = new Promise(function(resolve, reject) {
func = function(err) {
if (err) {
return reject(err)
}
resolve()
}
})
}

// 2. clean hemera
this.onShutdown((instance, done) => {
this._heavy.stop()
Expand All @@ -1583,15 +1569,7 @@ class Hemera extends EventEmitter {
})
})

// 3. run user function
this.shutdown(err => {
if (err) {
this.log.error(err)
}
func(err)
})

return promise
return this.shutdown(func)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/hemera/package.json
Expand Up @@ -43,7 +43,7 @@
"@types/pino": "^4.16.0"
},
"dependencies": {
"avvio": "5.6.x",
"avvio": "5.7.x",
"bloomrun": "4.1.x",
"errio": "1.2.x",
"fast-safe-stringify": "2.0.x",
Expand Down

0 comments on commit 9a9fd1b

Please sign in to comment.