From 1eed6dff34ba642eef74a64e2b577f990e93bcbd Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 19 Oct 2017 11:23:42 -0700 Subject: [PATCH] Make clean command top level (#12616) * Make clean command top level Fixes https://github.com/flutter/flutter/issues/10783 * remove backwards --- packages/flutter_tools/lib/executable.dart | 2 + .../flutter_tools/lib/src/commands/build.dart | 30 --------------- .../flutter_tools/lib/src/commands/clean.dart | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 packages/flutter_tools/lib/src/commands/clean.dart diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index 53f40b39dcc..b7c4050660f 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -24,6 +24,7 @@ import 'src/cache.dart'; import 'src/commands/analyze.dart'; import 'src/commands/build.dart'; import 'src/commands/channel.dart'; +import 'src/commands/clean.dart'; import 'src/commands/config.dart'; import 'src/commands/create.dart'; import 'src/commands/daemon.dart'; @@ -68,6 +69,7 @@ Future main(List args) async { new AnalyzeCommand(verboseHelp: verboseHelp), new BuildCommand(verboseHelp: verboseHelp), new ChannelCommand(), + new CleanCommand(), new ConfigCommand(verboseHelp: verboseHelp), new CreateCommand(), new DaemonCommand(hidden: !verboseHelp), diff --git a/packages/flutter_tools/lib/src/commands/build.dart b/packages/flutter_tools/lib/src/commands/build.dart index 06dd9e4771d..61ebf86b837 100644 --- a/packages/flutter_tools/lib/src/commands/build.dart +++ b/packages/flutter_tools/lib/src/commands/build.dart @@ -6,10 +6,8 @@ import 'dart:async'; import 'package:meta/meta.dart'; -import '../base/common.dart'; import '../base/file_system.dart'; import '../base/utils.dart'; -import '../build_info.dart'; import '../globals.dart'; import '../runner/flutter_command.dart'; import 'build_aot.dart'; @@ -21,7 +19,6 @@ class BuildCommand extends FlutterCommand { BuildCommand({bool verboseHelp: false}) { addSubcommand(new BuildApkCommand()); addSubcommand(new BuildAotCommand()); - addSubcommand(new BuildCleanCommand()); addSubcommand(new BuildIOSCommand()); addSubcommand(new BuildFlxCommand(verboseHelp: verboseHelp)); } @@ -61,30 +58,3 @@ abstract class BuildSubCommand extends FlutterCommand { } } } - -class BuildCleanCommand extends FlutterCommand { - BuildCleanCommand() { - requiresPubspecYaml(); - } - - @override - final String name = 'clean'; - - @override - final String description = 'Delete the build/ directory.'; - - @override - Future runCommand() async { - final Directory buildDir = fs.directory(getBuildDirectory()); - printStatus("Deleting '${buildDir.path}${fs.path.separator}'."); - - if (!buildDir.existsSync()) - return; - - try { - buildDir.deleteSync(recursive: true); - } catch (error) { - throwToolExit(error.toString()); - } - } -} diff --git a/packages/flutter_tools/lib/src/commands/clean.dart b/packages/flutter_tools/lib/src/commands/clean.dart new file mode 100644 index 00000000000..f2e65a3b35b --- /dev/null +++ b/packages/flutter_tools/lib/src/commands/clean.dart @@ -0,0 +1,38 @@ +// Copyright 2017 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 '../base/common.dart'; +import '../base/file_system.dart'; +import '../build_info.dart'; +import '../globals.dart'; +import '../runner/flutter_command.dart'; + +class CleanCommand extends FlutterCommand { + CleanCommand() { + requiresPubspecYaml(); + } + + @override + final String name = 'clean'; + + @override + final String description = 'Delete the build/ directory.'; + + @override + Future runCommand() async { + final Directory buildDir = fs.directory(getBuildDirectory()); + printStatus("Deleting '${buildDir.path}${fs.path.separator}'."); + + if (!buildDir.existsSync()) + return; + + try { + buildDir.deleteSync(recursive: true); + } catch (error) { + throwToolExit(error.toString()); + } + } +}