File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -22,23 +22,38 @@ module.exports = (connection) => {
22
22
23
23
params = parseParams ( commands [ command ] , args ) ;
24
24
25
- } else if ( args instanceof Function && ! cb ) {
26
-
27
- cb = args ;
28
-
29
25
} else if ( Array . isArray ( args ) || args === null || args === undefined ) {
30
26
31
27
params = args ;
32
28
33
- } else {
29
+ } else if ( args instanceof Function && ! cb ) {
30
+
31
+ cb = args ;
32
+
33
+ } else if ( args != undefined ) {
34
34
35
35
throw `${ args } is invalid input.`
36
36
37
37
}
38
38
39
- client . call ( command . toLowerCase ( ) , params , ( err , res ) => {
40
- cb ( err , res ) ;
41
- } )
39
+ let promiseReturn = null ;
40
+
41
+ if ( ! cb ) {
42
+ promiseReturn = new Promise ( ( resolve , reject ) => {
43
+ cb = ( err , res ) => {
44
+ if ( err ) {
45
+ return reject ( err ) ;
46
+ }
47
+ resolve ( res ) ;
48
+ }
49
+ } )
50
+ }
51
+
52
+
53
+ client . call ( command . toLowerCase ( ) , params , cb ) ;
54
+
55
+ return promiseReturn ;
56
+
42
57
}
43
58
}
44
59
return caller ;
You can’t perform that action at this time.
0 commit comments