From 7d2ad74c27ef1709bde88cc90b5c7c796787e7b0 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 8 Jun 2018 13:45:01 -0400 Subject: [PATCH] +1 --- CHANGELOG.md | 3 +++ lib/angel_hot.dart | 37 ++++++++++++++++++------------------- pubspec.yaml | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7913b0e8..35381a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.1.1+1 +* Fix a bug that threw when `--observe` was not present. + # 1.1.1 * Disable the observatory from pausing the isolate on exceptions, because Angel already handles diff --git a/lib/angel_hot.dart b/lib/angel_hot.dart index 8cae376a..f02866cd 100644 --- a/lib/angel_hot.dart +++ b/lib/angel_hot.dart @@ -140,37 +140,36 @@ class HotReloader { /// Starts listening to requests and filesystem events. Future startServer([address, int port]) async { + _server = await _generateServer(); + if (_paths?.isNotEmpty != true) print( 'WARNING: You have instantiated a HotReloader without providing any filesystem paths to watch.'); - _client = await vm.vmServiceConnect( - vmServiceHost ?? 'localhost', vmServicePort ?? 8181); - _vmachine ??= await _client.getVM(); - _mainIsolate ??= _vmachine.isolates.first; - await _client.setExceptionPauseMode(_mainIsolate.id, 'None'); + if (!Platform.executableArguments.contains('--observe') && + !Platform.executableArguments.contains('--enable-vm-service')) { + stderr.writeln( + 'WARNING: You have instantiated a HotReloader without passing `--enable-vm-service` or `--observe` to the Dart VM. Hot reloading will be disabled.'); + } else { + _client = await vm.vmServiceConnect( + vmServiceHost ?? 'localhost', vmServicePort ?? 8181); + _vmachine ??= await _client.getVM(); + _mainIsolate ??= _vmachine.isolates.first; + await _client.setExceptionPauseMode(_mainIsolate.id, 'None'); + + _onChange.stream + .transform(new _Debounce(new Duration(seconds: 1))) + .listen(_handleWatchEvent); + await _listenToFilesystem(); + } - _server = await _generateServer(); while (!_requestQueue.isEmpty) await _handle(_requestQueue.removeFirst()); - - _onChange.stream - .transform(new _Debounce(new Duration(seconds: 1))) - .listen(_handleWatchEvent); - await _listenToFilesystem(); - var server = await HttpServer.bind(address ?? '127.0.0.1', port ?? 0); server.listen(handleRequest); return server; } _listenToFilesystem() async { - if (!Platform.executableArguments.contains('--observe') && - !Platform.executableArguments.contains('--enable-vm-service')) { - stderr.writeln( - 'WARNING: You have instantiated a HotReloader without passing `--enable-vm-service` or `--observe` to the Dart VM. Hot reloading will be disabled.'); - return; - } - for (var path in _paths) { if (path is String) { await _listenToStat(path); diff --git a/pubspec.yaml b/pubspec.yaml index a370a2e4..bfd6967f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_hot description: Supports hot reloading of Angel servers on file changes. -version: 1.1.1 +version: 1.1.1+1 author: Tobe O homepage: https://github.com/angel-dart/hot environment: