Permalink
Browse files

Return meaningful error when no devices available

Summary:
`react-native run-ios --device` should report 'No iOS devices connected.' in case when no devices attached. However due to logic bug when empty array is being treatened as a boolean value, cli reports odd message, saying `Could not find device with the name: "true".`

Disconnect all iOS devices from developer machine and run `react-native run-ios --device` in any project - console message should state that there are no devices available.
Closes #15603

Differential Revision: D5686891

Pulled By: shergin

fbshipit-source-id: 289461b6f920691ad39e940ecca6d85cf2a3573b
  • Loading branch information...
vladimir-kotikov authored and facebook-github-bot committed Aug 23, 2017
1 parent 743dc20 commit ad4aee75199efbab8d028403d0459b74bf9d3816
Showing with 6 additions and 6 deletions.
  1. +6 −6 local-cli/runIOS/runIOS.js
View
@@ -47,10 +47,10 @@ function runIOS(argv, config, args) {
);
if (args.device) {
const selectedDevice = matchingDevice(devices, args.device);
if (selectedDevice){
if (selectedDevice) {
return runOnDevice(selectedDevice, scheme, xcodeProject, args.configuration, args.packager);
} else {
if (devices){
if (devices && devices.length > 0) {
console.log('Could not find device with the name: "' + args.device + '".');
console.log('Choose one of the following:');
printFoundDevices(devices);
@@ -67,10 +67,10 @@ function runIOS(argv, config, args) {
function runOnDeviceByUdid(args, scheme, xcodeProject, devices) {
const selectedDevice = matchingDeviceByUdid(devices, args.udid);
if (selectedDevice){
if (selectedDevice) {
return runOnDevice(selectedDevice, scheme, xcodeProject, args.configuration, args.packager);
} else {
if (devices){
if (devices && devices.length > 0) {
console.log('Could not find device with the udid: "' + args.udid + '".');
console.log('Choose one of the following:');
printFoundDevices(devices);
@@ -80,7 +80,7 @@ function runOnDeviceByUdid(args, scheme, xcodeProject, devices) {
}
}
function runOnSimulator(xcodeProject, args, scheme){
function runOnSimulator(xcodeProject, args, scheme) {
return new Promise((resolve) => {
try {
var simulators = JSON.parse(
@@ -205,7 +205,7 @@ function formattedDeviceName(simulator) {
return `${simulator.name} (${simulator.version})`;
}
function printFoundDevices(devices){
function printFoundDevices(devices) {
for (let i = devices.length - 1; i >= 0; i--) {
console.log(devices[i].name + ' Udid: ' + devices[i].udid);
}

0 comments on commit ad4aee7

Please sign in to comment.