From aed056c64b0ce355860e908a66d6e3149239e1bc Mon Sep 17 00:00:00 2001 From: Dan Rubel Date: Wed, 5 Oct 2016 14:11:41 -0400 Subject: [PATCH] remove flutter listen (#6198) --- packages/flutter_tools/lib/executable.dart | 2 - .../lib/src/commands/listen.dart | 129 ------------------ packages/flutter_tools/test/all.dart | 2 - packages/flutter_tools/test/listen_test.dart | 22 --- 4 files changed, 155 deletions(-) delete mode 100644 packages/flutter_tools/lib/src/commands/listen.dart delete mode 100644 packages/flutter_tools/test/listen_test.dart diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index dc65fc3df9c..771398c0a7c 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -23,7 +23,6 @@ import 'src/commands/doctor.dart'; import 'src/commands/drive.dart'; import 'src/commands/format.dart'; import 'src/commands/install.dart'; -import 'src/commands/listen.dart'; import 'src/commands/logs.dart'; import 'src/commands/setup.dart'; import 'src/commands/packages.dart'; @@ -70,7 +69,6 @@ Future main(List args) async { ..addCommand(new DriveCommand()) ..addCommand(new FormatCommand()) ..addCommand(new InstallCommand()) - ..addCommand(new ListenCommand()) ..addCommand(new LogsCommand()) ..addCommand(new PackagesCommand()) ..addCommand(new PrecacheCommand()) diff --git a/packages/flutter_tools/lib/src/commands/listen.dart b/packages/flutter_tools/lib/src/commands/listen.dart deleted file mode 100644 index db6f8e7e07d..00000000000 --- a/packages/flutter_tools/lib/src/commands/listen.dart +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:io'; - -import '../base/os.dart'; -import '../base/process.dart'; -import '../cache.dart'; -import '../device.dart'; -import '../globals.dart'; -import 'run.dart'; - -class ListenCommand extends RunCommandBase { - ListenCommand({ this.singleRun: false }); - - @override - final String name = 'listen'; - - @override - final String description = 'Listen for changes to files and reload the running app.'; - - @override - final String usageFooter = - 'By default, only listens to "./" and "./lib/". To listen to additional directories, list them on\n' - 'the command line.'; - - /// Only run once. Used for testing. - final bool singleRun; - - Device device; - - @override - Future verifyThenRunCommand() async { - if (!commandValidator()) - return 1; - device = await findTargetDevice(); - if (device == null) - return 1; - return super.verifyThenRunCommand(); - } - - @override - Future runCommand() async { - Iterable directories = () sync* { - yield* argResults.rest; - yield '.'; - yield 'lib'; - }(); - - List watchCommand = _constructWatchCommand(directories); - - if (watchCommand == null) - return 1; - - Cache.releaseLockEarly(); - - printStatus('Listening for changes in ' - '${directories.map((String name) => "'$name${Platform.pathSeparator}'").join(', ')}' - '.'); - - int result = 0; - bool firstTime = true; - do { - printStatus(''); - - // TODO(devoncarew): We could print out here what changes we detected that caused a re-run. - if (!firstTime) - printStatus('Re-running app...'); - - result = await startApp( - device, - target: targetFile, - install: firstTime, - stop: true, - debuggingOptions: new DebuggingOptions.enabled(getBuildMode()), - traceStartup: traceStartup, - route: route - ); - firstTime = false; - } while (!singleRun && result == 0 && _watchDirectory(watchCommand)); - - return 0; - } - - List _constructWatchCommand(Iterable directories) { - if (Platform.isMacOS) { - if (os.which('fswatch') == null) { - printError('"listen" command is only useful if you have installed ' - 'fswatch on Mac. Run "brew install fswatch" to install it with homebrew.'); - return null; - } else { - return ['fswatch', '-r', '-v', '-1']..addAll(directories); - } - } else if (Platform.isLinux) { - if (os.which('inotifywait') == null) { - printError('"listen" command is only useful if you have installed ' - 'inotifywait on Linux. Run "apt-get install inotify-tools" or ' - 'equivalent to install it.'); - return null; - } else { - return [ - 'inotifywait', - '-r', - '-e', - // Only listen for events that matter, to avoid triggering constantly - // from the editor watching files. - 'modify,close_write,move,create,delete', - ]..addAll(directories); - } - } else { - printError('"listen" command is only available on Mac and Linux.'); - } - - return null; - } - - bool _watchDirectory(List watchCommand) { - assert(watchCommand != null); - try { - runCheckedSync(watchCommand); - } catch (e) { - printError('Watching directories failed.', e); - return false; - } - return true; - } -} diff --git a/packages/flutter_tools/test/all.dart b/packages/flutter_tools/test/all.dart index 32a71074502..201f6675432 100644 --- a/packages/flutter_tools/test/all.dart +++ b/packages/flutter_tools/test/all.dart @@ -28,7 +28,6 @@ import 'devices_test.dart' as devices_test; import 'drive_test.dart' as drive_test; import 'format_test.dart' as format_test; import 'install_test.dart' as install_test; -import 'listen_test.dart' as listen_test; import 'logs_test.dart' as logs_test; import 'os_utils_test.dart' as os_utils_test; import 'packages_test.dart' as packages_test; @@ -62,7 +61,6 @@ void main() { drive_test.main(); format_test.main(); install_test.main(); - listen_test.main(); logs_test.main(); os_utils_test.main(); packages_test.main(); diff --git a/packages/flutter_tools/test/listen_test.dart b/packages/flutter_tools/test/listen_test.dart deleted file mode 100644 index 9c7c87a520f..00000000000 --- a/packages/flutter_tools/test/listen_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter_tools/src/commands/listen.dart'; -import 'package:test/test.dart'; - -import 'src/common.dart'; -import 'src/context.dart'; -import 'src/mocks.dart'; - -void main() { - group('listen', () { - testUsingContext('returns 1 when no device is connected', () { - ListenCommand command = new ListenCommand(singleRun: true); - applyMocksToCommand(command); - return createTestCommandRunner(command).run(['listen']).then((int code) { - expect(code, 1); - }); - }); - }); -}