| commit | 1e8318e68da63b755fb65521fd2a8243fb0566fd | [log] [tgz] |
|---|---|---|
| author | Kevin Moore <kevmoo@users.noreply.github.com> | Fri Mar 19 08:32:56 2021 -0700 |
| committer | GitHub <noreply@github.com> | Fri Mar 19 08:32:56 2021 -0700 |
| tree | bc248e1cf15e6a9b0eeb9e8d625db7a8f8be0581 | |
| parent | 6b9d2ebdbb59f4e07d541215ee6ac28099ac31a3 [diff] |
Remove unneeded dart_style dep, remove dep overrides... (#74) Use latest setup-dart version Test on oldest supported Dart SDK Fix formatting
Contains utilities for the Dart VM's dart:io.
io.dartisExecutableReturns whether a provided file path is considered executable on the host operating system.
ExitCodeAn enum-like class that contains known exit codes.
ProcessManagerA higher-level service for spawning and communicating with processes.
spawn to create a process with std[in|out|err] forwarded by default/// 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(); }
sharedStdInA safer version of the default stdin stream from dart:io that allows a subscriber to cancel their subscription, and then allows a new subscriber to start listening. This differs from the default behavior where only a single listener is ever allowed in the application lifecycle:
test('should allow multiple subscribers', () async { final logs = <String>[]; final asUtf8 = sharedStdIn.transform(UTF8.decoder); // Wait for input for the user. logs.add(await asUtf8.first); // Wait for more input for the user. logs.add(await asUtf8.first); expect(logs, ['Hello World', 'Goodbye World']); });
For testing, an instance of SharedStdIn may be created directly.
ansi.dartimport 'dart:io' as io; import 'package:io/ansi.dart'; void main() { // To use one style, call the `wrap` method on one of the provided top-level // values. io.stderr.writeln(red.wrap("Bad error!")); // To use multiple styles, call `wrapWith`. print(wrapWith('** Important **', [red, styleBold, styleUnderlined])); // The wrap functions will simply return the provided value unchanged if // `ansiOutputEnabled` is false. // // You can override the value `ansiOutputEnabled` by wrapping code in // `overrideAnsiOutput`. overrideAnsiOutput(false, () { assert('Normal text' == green.wrap('Normal text')); }); }