| // Copyright 2019 The Flutter team. 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 'package:grinder/grinder.dart'; |
| import 'package:path/path.dart' as path; |
| |
| void main(List<String> args) => grind(args); |
| |
| @Task('Get packages') |
| Future<void> pubGet({String? directory}) async { |
| await _runProcess( |
| 'flutter', |
| ['pub', 'get', if (directory != null) directory], |
| ); |
| } |
| |
| @Task('Format dart files') |
| Future<void> format({String path = '.'}) async { |
| await _runProcess('flutter', ['format', path]); |
| } |
| |
| @Task('Transform arb to xml for English') |
| Future<void> l10n() async { |
| final l10nPath = |
| path.join(Directory.current.path, 'tool', 'l10n_cli', 'main.dart'); |
| Dart.run(l10nPath); |
| } |
| |
| @Task('Update code segments') |
| Future<void> updateCodeSegments() async { |
| final codeviewerPath = |
| path.join(Directory.current.path, 'tool', 'codeviewer_cli', 'main.dart'); |
| Dart.run(codeviewerPath); |
| } |
| |
| Future<void> _runProcess(String executable, List<String> arguments) async { |
| final result = await Process.run(executable, arguments); |
| stdout.write(result.stdout); |
| stderr.write(result.stderr); |
| } |