mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Add support for promises
This commit is contained in:
parent
42df8ed96b
commit
7b9fe2161c
4 changed files with 99 additions and 71 deletions
|
|
@ -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}));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue