blob: 59180573d51b39b95c8d91e1f9f4842545d7bba9 [file] [log] [blame]
// Copyright 2017, the Dart project authors. Please see the AUTHORS file
// for details. 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 'package:io/io.dart';
/// Runs `dartfmt` commands and `pub publish`.
Future<void> main() async {
final manager = ProcessManager();
// Runs dartfmt --version and outputs the result via stdout.
print('Running dartfmt --version');
var spawn = await manager.spawn('dartfmt', ['--version']);
await spawn.exitCode;
// Runs dartfmt -n . and outputs the result via stdout.
print('Running dartfmt -n .');
spawn = await manager.spawn('dartfmt', ['-n', '.']);
await spawn.exitCode;
// Runs pub publish. Upon hitting a blocking stdin state, you may directly
// output to the processes's stdin via your own, similar to how a bash or
// shell script would spawn a process.
print('Running pub publish');
spawn = await manager.spawn('pub', ['publish']);
await spawn.exitCode;
// Closes stdin for the entire program.
await sharedStdIn.terminate();
}