Add support for promises

This commit is contained in:
mmorrison 2017-03-14 03:40:02 -05:00
parent 42df8ed96b
commit 7b9fe2161c
4 changed files with 99 additions and 71 deletions

View file

@ -22,13 +22,19 @@ for(var key in argv) {
var Gamedig = require('../lib/index');
if(debug) Gamedig.debug = true;
Gamedig.isCommandLine = true;
Gamedig.query(
options,
function(state) {
Gamedig.query(options)
.then((state) => {
if(outputFormat == 'pretty') {
console.log(JSON.stringify(state,null,' '));
} else {
console.log(JSON.stringify(state));
}
}
);
})
.catch((error) => {
if(outputFormat == 'pretty') {
console.log(JSON.stringify({error:error},null,' '));
} else {
console.log(JSON.stringify({error:error}));
}
});