blob: ba2da00c857f64b8c8ba9b90db9d7d07ff2bbe85 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:async';
import 'dart:io' as io;
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path;
import 'environment.dart';
import 'utils.dart';
class CleanCommand extends Command<bool> with ArgUtils {
CleanCommand() {
defaultsTo: false,
help: 'Also clean up the engine out directory with ninja output.',
String get name => 'clean';
bool get _alsoCleanNinja => boolArg('ninja');
String get description => 'Deletes build caches and artifacts.';
FutureOr<bool> run() async {
final io.Directory assetsDir = io.Directory(path.join(
environment.webUiRootDir.path, 'lib', 'assets'
final Iterable<io.File> fontFiles = assetsDir
.where((io.File file) => file.path.endsWith('.ttf'));
final List<io.FileSystemEntity> thingsToBeCleaned = <io.FileSystemEntity>[
io.File(path.join(environment.webUiRootDir.path, '.packages')),
io.File(path.join(environment.webUiRootDir.path, 'pubspec.lock')),
if (_alsoCleanNinja)
await Future.wait(
.where((io.FileSystemEntity entity) => entity.existsSync())
.map((io.FileSystemEntity entity) => entity.delete(recursive: true))
return true;