Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Fix ProcessManager signatures to be consistent with LocalProcessManag…
Browse files Browse the repository at this point in the history
…er (#58)

When `LocalProcessManager.run`, `.runSync`, and `.start` were
migrated for null-safety, the base `ProcessManager` interface was not
updated.  This led to an inconsistency where the interface
unnecessarily required non-null versions of `workingDirectory` and
`environment`, which creates extra headache for clients.  This change
should be safe since it makes the base interface less restrictive.

Additionally, `LocalProcessManager` takes a covariant `List<Object>`
where the base interface takes `List<dynamic>`.  I don't see a need
for the interface to take `List<dynamic>` (which could accept `null`)
so change that too.  This change is less safe, although in practice
anything that attempted to pass `null` would already crash if using
the `LocalProcessManager` implementation anyway.

Fixes #56.
  • Loading branch information
jamesderlin authored Feb 12, 2021
1 parent 56ece43 commit 7ca6534
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### 4.0.1

* Fix the signatures of `ProcessManager.run`, `.runSync`, and `.start` to be
consistent with `LocalProcessManager`'s.

#### 4.0.0

* First stable null safe release.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/interface/local_process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LocalProcessManager implements ProcessManager {

@override
Future<Process> start(
covariant List<Object> command, {
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
Expand All @@ -53,7 +53,7 @@ class LocalProcessManager implements ProcessManager {

@override
Future<ProcessResult> run(
covariant List<Object> command, {
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
Expand All @@ -79,7 +79,7 @@ class LocalProcessManager implements ProcessManager {

@override
ProcessResult runSync(
covariant List<Object> command, {
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
Expand Down
18 changes: 9 additions & 9 deletions lib/src/interface/process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ abstract class ProcessManager {
///
/// The default value for `mode` is `ProcessStartMode.normal`.
Future<Process> start(
List<dynamic> command, {
String workingDirectory,
Map<String, String> environment,
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool runInShell = false,
ProcessStartMode mode = ProcessStartMode.normal,
Expand Down Expand Up @@ -136,9 +136,9 @@ abstract class ProcessManager {
/// stderr.write(result.stderr);
/// });
Future<ProcessResult> run(
List<dynamic> command, {
String workingDirectory,
Map<String, String> environment,
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool runInShell = false,
Encoding stdoutEncoding = systemEncoding,
Expand All @@ -153,9 +153,9 @@ abstract class ProcessManager {
/// Returns a `ProcessResult` with the result of running the process,
/// i.e., exit code, standard out and standard in.
ProcessResult runSync(
List<dynamic> command, {
String workingDirectory,
Map<String, String> environment,
List<Object> command, {
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool runInShell = false,
Encoding stdoutEncoding = systemEncoding,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: process
version: 4.0.0
version: 4.0.1
description: A pluggable, mockable process invocation abstraction for Dart.
homepage: https://github.com/google/process.dart

Expand Down

0 comments on commit 7ca6534

Please sign in to comment.