Skip to content

Commit d77306b

Browse files
committed
CB-14164 Use native Promises instead of Q
1 parent e45b432 commit d77306b

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

main.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
const url = require('url');
2424
const path = require('path');
2525

26-
const Q = require('q');
2726
const nopt = require('nopt');
2827

2928
const pkg = require('./package');
@@ -63,14 +62,7 @@ if (cli_opts.plugins_dir || cli_opts.project) {
6362
path.join(cli_opts.project, 'cordova', 'plugins');
6463
}
6564

66-
process.on('uncaughtException', function (error) {
67-
if (cli_opts.debug) {
68-
console.error(error.message, error.stack);
69-
} else {
70-
console.error(error.message);
71-
}
72-
process.exit(1);
73-
});
65+
process.on('uncaughtException', fail);
7466

7567
// Set up appropriate logging based on events
7668
if (cli_opts.debug) {
@@ -90,10 +82,16 @@ if (cli_opts.version) {
9082
} else if (cli_opts.help) {
9183
console.log(help());
9284
} else if (plugman.commands[cmd]) {
93-
var result = plugman.commands[cmd](cli_opts);
94-
if (result && Q.isPromise(result)) {
95-
result.done();
96-
}
85+
Promise.resolve(plugman.commands[cmd](cli_opts))
86+
.catch(fail);
9787
} else {
9888
console.log(help());
9989
}
90+
91+
function fail (error) {
92+
console.error(error.message);
93+
if (cli_opts.debug) {
94+
console.error(error.stack);
95+
}
96+
process.exit(1);
97+
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"engineStrict": true,
1919
"dependencies": {
2020
"cordova-lib": "8.0.0",
21-
"nopt": "1.0.9",
22-
"q": "1.0.1"
21+
"nopt": "1.0.9"
2322
},
2423
"devDependencies": {
2524
"eslint": "^4.2.0",

0 commit comments

Comments
 (0)