Skip to content

Commit

Permalink
fix: use unified target methods in platform-centric bins
Browse files Browse the repository at this point in the history
  • Loading branch information
raphinesse committed Nov 20, 2020
1 parent 72f4ed3 commit 0c62cd6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions bin/templates/cordova/lib/install-device
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
under the License.
*/

const { install } = require('./target');
var device = require('./device');
const { resolve, install } = require('./target');

var args = process.argv;
const targetSpec = { type: 'device' };

if (args.length > 2) {
var install_target;
if (args[2].substring(0, 9) === '--target=') {
install_target = args[2].substring(9, args[2].length);
targetSpec.id = args[2].substring(9, args[2].length);
} else {
console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
process.exit(2);
}
}

device.resolveTarget(install_target).then(install).catch(err => {
resolve(targetSpec).then(install).catch(err => {
console.error('ERROR: ' + err);
process.exit(2);
});
10 changes: 5 additions & 5 deletions bin/templates/cordova/lib/install-emulator
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
under the License.
*/

const { install } = require('./target');
var emulator = require('./emulator');
const { resolve, install } = require('./target');

var args = process.argv;
const targetSpec = { type: 'emulator' };

var install_target;
if (args.length > 2) {
if (args[2].substring(0, 9) === '--target=') {
install_target = args[2].substring(9, args[2].length);
targetSpec.id = args[2].substring(9, args[2].length);
} else {
console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
process.exit(2);
}
}

emulator.resolveTarget(install_target).then(install).catch(err => {
resolve(targetSpec).then(install).catch(err => {
console.error('ERROR: ' + err);
process.exit(2);
});
12 changes: 7 additions & 5 deletions bin/templates/cordova/lib/list-devices
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
under the License.
*/

var devices = require('./device');
const { list } = require('./target');

// Usage support for when args are given
require('./check_reqs').check_android().then(function () {
devices.list().then(function (device_list) {
device_list && device_list.forEach(function (dev) {
console.log(dev);
});
list().then(targets => {
const deviceIds = targets
.filter(({ type }) => type === 'device')
.map(({ id }) => id);

console.log(deviceIds.join('\n'));
}, function (err) {
console.error('ERROR: ' + err);
process.exit(2);
Expand Down

0 comments on commit 0c62cd6

Please sign in to comment.