Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pkgs/process/lib/src/interface/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ String? getExecutablePath(
// the cwd path. In this case, fall back on '.'.
workingDirectory ??= '.';
}
final Context context =
Context(style: fs.path.style, current: workingDirectory);
final Context context = Context(
style: fs.path.style,
current: workingDirectory,
);

// TODO(goderbauer): refactor when github.com/google/platform.dart/issues/2
// is available.
Expand All @@ -74,8 +76,12 @@ String? getExecutablePath(
? <String>[workingDirectory]
: platform.environment['PATH']!.split(pathSeparator);

final List<String> candidates =
_getCandidatePaths(executable, searchPath, extensions, context);
final List<String> candidates = _getCandidatePaths(
executable,
searchPath,
extensions,
context,
);
final List<String> foundCandidates = <String>[];
for (final String path in candidates) {
final File candidate = fs.file(path);
Expand Down Expand Up @@ -146,8 +152,10 @@ List<String> _getCandidatePaths(
return withExtensions;
}
return searchPaths
.map((String path) =>
withExtensions.map((String command) => context.join(path, command)))
.map(
(String path) =>
withExtensions.map((String command) => context.join(path, command)),
)
.expand((Iterable<String> e) => e)
.toList()
.cast<String>();
Expand Down
5 changes: 3 additions & 2 deletions pkgs/process/lib/src/interface/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class ProcessPackageExecutableNotFoundException

@override
String toString() {
final StringBuffer buffer =
StringBuffer('ProcessPackageExecutableNotFoundException: $message\n');
final StringBuffer buffer = StringBuffer(
'ProcessPackageExecutableNotFoundException: $message\n',
);
// Don't add an extra space if there are no arguments.
final String args = arguments.isNotEmpty ? ' ${arguments.join(' ')}' : '';
buffer.writeln(' Command: $executable$args');
Expand Down
41 changes: 19 additions & 22 deletions pkgs/process/lib/src/interface/local_process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ class LocalProcessManager implements ProcessManager {
}) {
try {
return Process.start(
_getExecutable(
command,
workingDirectory,
runInShell,
),
_getExecutable(command, workingDirectory, runInShell),
_getArguments(command),
workingDirectory: workingDirectory,
environment: environment,
Expand All @@ -53,8 +49,10 @@ class LocalProcessManager implements ProcessManager {
mode: mode,
);
} on ProcessException catch (exception) {
throw ProcessPackageException.fromProcessException(exception,
workingDirectory: workingDirectory);
throw ProcessPackageException.fromProcessException(
exception,
workingDirectory: workingDirectory,
);
}
}

Expand All @@ -70,11 +68,7 @@ class LocalProcessManager implements ProcessManager {
}) {
try {
return Process.run(
_getExecutable(
command,
workingDirectory,
runInShell,
),
_getExecutable(command, workingDirectory, runInShell),
_getArguments(command),
workingDirectory: workingDirectory,
environment: environment,
Expand All @@ -84,8 +78,10 @@ class LocalProcessManager implements ProcessManager {
stderrEncoding: stderrEncoding,
);
} on ProcessException catch (exception) {
throw ProcessPackageException.fromProcessException(exception,
workingDirectory: workingDirectory);
throw ProcessPackageException.fromProcessException(
exception,
workingDirectory: workingDirectory,
);
}
}

Expand All @@ -101,11 +97,7 @@ class LocalProcessManager implements ProcessManager {
}) {
try {
return Process.runSync(
_getExecutable(
command,
workingDirectory,
runInShell,
),
_getExecutable(command, workingDirectory, runInShell),
_getArguments(command),
workingDirectory: workingDirectory,
environment: environment,
Expand All @@ -115,8 +107,10 @@ class LocalProcessManager implements ProcessManager {
stderrEncoding: stderrEncoding,
);
} on ProcessException catch (exception) {
throw ProcessPackageException.fromProcessException(exception,
workingDirectory: workingDirectory);
throw ProcessPackageException.fromProcessException(
exception,
workingDirectory: workingDirectory,
);
}
}

Expand All @@ -131,7 +125,10 @@ class LocalProcessManager implements ProcessManager {
}

String _getExecutable(
List<dynamic> command, String? workingDirectory, bool runInShell) {
List<dynamic> command,
Comment thread
kevmoo marked this conversation as resolved.
Resolved
String? workingDirectory,
bool runInShell,
) {
final String commandName = command.first.toString();
if (runInShell) {
return commandName;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/process/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: process
description: A pluggable, mockable process invocation abstraction for Dart.
version: 5.0.5
version: 5.0.6-wip
repository: https://github.com/dart-lang/tools/tree/main/pkgs/process
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aprocess

Expand Down
Loading
Loading