CB-14158: Refactor device to remove Q

This commit is contained in:
Gearoid M 2018-07-03 10:34:31 +09:00
parent ca8931c8af
commit bd07907a4c
3 changed files with 6 additions and 7 deletions

View File

@ -19,7 +19,6 @@
under the License. under the License.
*/ */
var Q = require('q');
var build = require('./build'); var build = require('./build');
var path = require('path'); var path = require('path');
var Adb = require('./Adb'); var Adb = require('./Adb');
@ -53,13 +52,13 @@ module.exports.list = function (lookHarder) {
module.exports.resolveTarget = function (target) { module.exports.resolveTarget = function (target) {
return this.list(true).then(function (device_list) { return this.list(true).then(function (device_list) {
if (!device_list || !device_list.length) { 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 // default device
target = target || device_list[0]; target = target || device_list[0];
if (device_list.indexOf(target) < 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) { return build.detectArchitecture(target).then(function (arch) {
@ -74,7 +73,7 @@ module.exports.resolveTarget = function (target) {
* Returns a promise. * Returns a promise.
*/ */
module.exports.install = function (target, buildResults) { module.exports.install = function (target, buildResults) {
return Q().then(function () { return Promise.resolve().then(function () {
if (target && typeof target === 'object') { if (target && typeof target === 'object') {
return target; return target;
} }

View File

@ -26,7 +26,7 @@ if (args.length > 2) {
var install_target; var install_target;
if (args[2].substring(0, 9) === '--target=') { if (args[2].substring(0, 9) === '--target=') {
install_target = args[2].substring(9, args[2].length); 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); console.error('ERROR: ' + err);
process.exit(2); process.exit(2);
}); });
@ -35,7 +35,7 @@ if (args.length > 2) {
process.exit(2); process.exit(2);
} }
} else { } else {
device.install().done(null, function (err) { device.install().catch(function (err) {
console.error('ERROR: ' + err); console.error('ERROR: ' + err);
process.exit(2); process.exit(2);
}); });

View File

@ -23,7 +23,7 @@ var devices = require('./device');
// Usage support for when args are given // Usage support for when args are given
require('./check_reqs').check_android().then(function () { 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) { device_list && device_list.forEach(function (dev) {
console.log(dev); console.log(dev);
}); });