[fuchsia] Get Dart VM service ports from The Hub (#25332)

This commit is contained in:
Zachary Anderson
2018-12-17 11:10:47 -08:00
committed by GitHub
parent 9619b53d06
commit b18a2b1794
5 changed files with 61 additions and 72 deletions

View File

@@ -13,9 +13,6 @@ import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart
import 'error.dart';
// TODO(awdavies): Update this to use the hub.
final Directory _kDartPortDir = Directory('/tmp/dart.services');
class _DummyPortForwarder implements PortForwarder {
_DummyPortForwarder(this._port, this._remotePort);
@@ -49,13 +46,13 @@ class _DummySshCommandRunner implements SshCommandRunner {
@override
Future<List<String>> run(String command) async {
try {
return List<String>.of(_kDartPortDir
.listSync(recursive: false, followLinks: false)
.map((FileSystemEntity entity) => entity.path
.replaceAll(entity.parent.path, '')
.replaceFirst(Platform.pathSeparator, '')));
} on FileSystemException catch (e) {
_log.warning('Error listing directory: $e');
final List<String> splitCommand = command.split(' ');
final String exe = splitCommand[0];
final List<String> args = splitCommand.skip(1).toList();
final ProcessResult r = Process.runSync(exe, args);
return r.stdout.split('\n');
} on ProcessException catch (e) {
_log.warning("Error running '$command': $e");
}
return <String>[];
}