From bd07907a4cdef69522ffcf4b4e0217f766e8029b Mon Sep 17 00:00:00 2001 From: Gearoid M Date: Tue, 3 Jul 2018 10:34:31 +0900 Subject: [PATCH] CB-14158: Refactor device to remove Q --- bin/templates/cordova/lib/device.js | 7 +++---- bin/templates/cordova/lib/install-device | 4 ++-- bin/templates/cordova/lib/list-devices | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/templates/cordova/lib/device.js b/bin/templates/cordova/lib/device.js index 84b50947..b186f817 100644 --- a/bin/templates/cordova/lib/device.js +++ b/bin/templates/cordova/lib/device.js @@ -19,7 +19,6 @@ under the License. */ -var Q = require('q'); var build = require('./build'); var path = require('path'); var Adb = require('./Adb'); @@ -53,13 +52,13 @@ module.exports.list = function (lookHarder) { module.exports.resolveTarget = function (target) { return this.list(true).then(function (device_list) { if (!device_list || !device_list.length) { - return Q.reject(new CordovaError('Failed to deploy to device, no devices found.')); + return Promise.reject(new CordovaError('Failed to deploy to device, no devices found.')); } // default device target = target || device_list[0]; if (device_list.indexOf(target) < 0) { - return Q.reject('ERROR: Unable to find target \'' + target + '\'.'); + return Promise.reject(new CordovaError('ERROR: Unable to find target \'' + target + '\'.')); } return build.detectArchitecture(target).then(function (arch) { @@ -74,7 +73,7 @@ module.exports.resolveTarget = function (target) { * Returns a promise. */ module.exports.install = function (target, buildResults) { - return Q().then(function () { + return Promise.resolve().then(function () { if (target && typeof target === 'object') { return target; } diff --git a/bin/templates/cordova/lib/install-device b/bin/templates/cordova/lib/install-device index 48b03f81..03873883 100755 --- a/bin/templates/cordova/lib/install-device +++ b/bin/templates/cordova/lib/install-device @@ -26,7 +26,7 @@ if (args.length > 2) { var install_target; if (args[2].substring(0, 9) === '--target=') { install_target = args[2].substring(9, args[2].length); - device.install(install_target).done(null, function (err) { + device.install(install_target).catch(function (err) { console.error('ERROR: ' + err); process.exit(2); }); @@ -35,7 +35,7 @@ if (args.length > 2) { process.exit(2); } } else { - device.install().done(null, function (err) { + device.install().catch(function (err) { console.error('ERROR: ' + err); process.exit(2); }); diff --git a/bin/templates/cordova/lib/list-devices b/bin/templates/cordova/lib/list-devices index e0f38211..339c6658 100755 --- a/bin/templates/cordova/lib/list-devices +++ b/bin/templates/cordova/lib/list-devices @@ -23,7 +23,7 @@ var devices = require('./device'); // Usage support for when args are given require('./check_reqs').check_android().then(function () { - devices.list().done(function (device_list) { + devices.list().then(function (device_list) { device_list && device_list.forEach(function (dev) { console.log(dev); });