Commit 4eb4dab5 authored by Eric Seidel's avatar Eric Seidel

Merge pull request #1350 from eseidelGoogle/list_linux

Make `flutter list` not crash on linux.
parents ed346222 7f3ae43b
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import '../android/device_android.dart';
import '../ios/device_ios.dart';
......@@ -43,25 +44,27 @@ class ListCommand extends FlutterCommand {
}
}
if (details)
print('iOS Devices:');
if (Platform.isMacOS) {
if (details)
print('iOS Devices:');
for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) {
if (details) {
print('${device.id}\t${device.name}');
} else {
print(device.id);
for (IOSDevice device in IOSDevice.getAttachedDevices(devices.iOS)) {
if (details) {
print('${device.id}\t${device.name}');
} else {
print(device.id);
}
}
}
if (details)
print('iOS Simulators:');
if (details)
print('iOS Simulators:');
for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) {
if (details) {
print('${device.id}\t${device.name}');
} else {
print(device.id);
for (IOSSimulator device in IOSSimulator.getAttachedDevices(devices.iOSSimulator)) {
if (details) {
print('${device.id}\t${device.name}');
} else {
print(device.id);
}
}
}
......
......@@ -21,10 +21,6 @@ class IOSDevice extends Device {
'To work with iOS devices, please install ideviceinstaller. '
'If you use homebrew, you can install it with '
'"\$ brew install ideviceinstaller".';
static const String _linuxInstructions =
'To work with iOS devices, please install ideviceinstaller. '
'On Ubuntu or Debian, you can install it with '
'"\$ apt-get install ideviceinstaller".';
String _installerPath;
String get installerPath => _installerPath;
......@@ -100,19 +96,16 @@ class IOSDevice extends Device {
static final Map<String, String> _commandMap = {};
static String _checkForCommand(
String command, [
String macInstructions = _macInstructions,
String linuxInstructions = _linuxInstructions
String macInstructions = _macInstructions
]) {
return _commandMap.putIfAbsent(command, () {
try {
command = runCheckedSync(['which', command]).trim();
} catch (e) {
if (Platform.isMacOS) {
logging.severe(macInstructions);
} else if (Platform.isLinux) {
logging.severe(linuxInstructions);
logging.severe('$command not found. $macInstructions');
} else {
logging.severe('$command is not available on your platform.');
logging.severe('Cannot control iOS devices or simulators. $command is not available on your platform.');
}
}
return command;
......@@ -331,9 +324,12 @@ class IOSSimulator extends Device {
static List<IOSSimulator> getAttachedDevices([IOSSimulator mockIOS]) {
List<IOSSimulator> devices = [];
_IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS);
if (deviceInfo != null)
devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name));
try {
_IOSSimulatorInfo deviceInfo = _getRunningSimulatorInfo(mockIOS);
if (deviceInfo != null)
devices.add(new IOSSimulator(id: deviceInfo.id, name: deviceInfo.name));
} catch (e) {
}
return devices;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment