Added printOutputDefault to the ProcessRunner constructor
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e7c437..9a06f22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,5 +1,10 @@ # Change Log for `process_runner` +## 2.0.4 + +* Added `printOutputDefault` to the `ProcessRunner` constructor, and updated + docs. + ## 2.0.3 * Updated [README.md](README.md) to fix a broken example. Bumping version to get
diff --git a/lib/src/process_runner.dart b/lib/src/process_runner.dart index d9959a6..80cbb2f 100644 --- a/lib/src/process_runner.dart +++ b/lib/src/process_runner.dart
@@ -115,6 +115,7 @@ this.processManager = const LocalProcessManager(), Map<String, String> environment, this.includeParentEnvironment = true, + this.printOutputDefault = false, this.decoder = const SystemEncoding(), }) : defaultWorkingDirectory = defaultWorkingDirectory ?? Directory.current, environment = environment ?? Map<String, String>.from(defaultPlatform.environment); @@ -145,6 +146,16 @@ /// If false, uses [environment] as the entire environment to run in. final bool includeParentEnvironment; + /// If set, indicates that, by default, commands will both write the output to + /// stdout/stderr, as well as return it in the [ProcessRunnerResult.stderr], + /// [ProcessRunnerResult.stderr] members. + /// + /// This setting can be overridden on a per-run basis by providing + /// `printOutput` to the [runProcess] function. + /// + /// Defaults to false. + final bool printOutputDefault; + /// The decoder to use for decoding result stderr, stdout, and output. /// /// Defaults to an instance of [SystemEncoding]. @@ -156,14 +167,22 @@ /// /// Set `failOk` if [runProcess] should not throw an exception when the /// command completes with a a non-zero exit code. + /// + /// If `printOutput` is set, indicates that the command will both write the + /// output to stdout/stderr, as well as return it in the + /// [ProcessRunnerResult.stderr], [ProcessRunnerResult.stderr] members of the + /// result. This overrides the setting of [printOutputDefault]. + /// + /// The `printOutput` argument defaults to the value of [printOutputDefault]. Future<ProcessRunnerResult> runProcess( List<String> commandLine, { Directory workingDirectory, - bool printOutput = false, + bool printOutput, bool failOk = false, Stream<List<int>> stdin, }) async { workingDirectory ??= defaultWorkingDirectory; + printOutput ??= printOutputDefault; if (printOutput) { stderr.write('Running "${commandLine.join(' ')}" in ${workingDirectory.path}.\n'); }
diff --git a/pubspec.yaml b/pubspec.yaml index 6556155..6098819 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -3,7 +3,7 @@ # found in the LICENSE file. name: process_runner -version: 2.0.3 +version: 2.0.4 description: A process invocation astraction for Dart that manages a multiprocess queue. homepage: https://github.com/google/process_runner