Fixes phonegap/ios-deploy#80 (re-fix) --detect not showing non-zero exit code when no devices are detected.

When --detect is turned on, --debug is turned on implicitly so you won't get a segmentation fault.
This commit is contained in:
Shazron Abdullah 2014-11-16 20:49:33 -08:00
parent 7c9af71d86
commit 33f6a83e1d
2 changed files with 10 additions and 6 deletions

View File

@ -16,7 +16,7 @@
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include "MobileDevice.h" #include "MobileDevice.h"
#define APP_VERSION "1.3.1" #define APP_VERSION "1.3.2"
#define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-" #define PREP_CMDS_PATH "/tmp/fruitstrap-lldb-prep-cmds-"
#define LLDB_SHELL "lldb -s " PREP_CMDS_PATH #define LLDB_SHELL "lldb -s " PREP_CMDS_PATH
/* /*
@ -1448,6 +1448,7 @@ void handle_device(AMDeviceRef device) {
if (detect_only) { if (detect_only) {
printf("[....] Found %s connected through %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding())); printf("[....] Found %s connected through %s.\n", CFStringGetCStringPtr(device_full_name, CFStringGetSystemEncoding()), CFStringGetCStringPtr(device_interface_name, CFStringGetSystemEncoding()));
found_device = true;
return; return;
} }
if (device_id != NULL) { if (device_id != NULL) {
@ -1609,10 +1610,12 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
{ {
if (!debug) { if (!debug) {
printf("[....] No more devices found.\n"); printf("[....] No more devices found.\n");
exit(exitcode_error);
} }
else
{ if (detect_only && !found_device) {
exit(exitcode_error);
return;
} else {
int mypid = getpid(); int mypid = getpid();
if ((parent != 0) && (parent == mypid) && (child != 0)) if ((parent != 0) && (parent == mypid) && (child != 0))
{ {
@ -1630,7 +1633,7 @@ void timeout_callback(CFRunLoopTimerRef timer, void *info) {
void usage(const char* app) { void usage(const char* app) {
printf( printf(
"Usage: %s [OPTION]...\n" "Usage: %s [OPTION]...\n"
" -d, --debug launch the app in GDB after installation\n" " -d, --debug launch the app in lldb after installation\n"
" -i, --id <device_id> the id of the device to connect to\n" " -i, --id <device_id> the id of the device to connect to\n"
" -c, --detect only detect if the device is connected\n" " -c, --detect only detect if the device is connected\n"
" -b, --bundle <bundle.app> the path to the app bundle to be installed\n" " -b, --bundle <bundle.app> the path to the app bundle to be installed\n"
@ -1723,6 +1726,7 @@ int main(int argc, char *argv[]) {
break; break;
case 'c': case 'c':
detect_only = true; detect_only = true;
debug = 1;
break; break;
case 'V': case 'V':
show_version(); show_version();

View File

@ -1,6 +1,6 @@
{ {
"name": "ios-deploy", "name": "ios-deploy",
"version": "1.3.1", "version": "1.3.2",
"description": "launch iOS apps iOS devices from the command line (Xcode 6)", "description": "launch iOS apps iOS devices from the command line (Xcode 6)",
"main": "ios-deploy", "main": "ios-deploy",
"scripts": { "scripts": {