run method
Future<ProcessResult>
run(
- String script, {
- Map<
String, String> ? environment, - Stream<
List< ? stdin,int> > - StreamSink<
List< ? stdout,int> > - List<
String> ? args,
override
Runs a command within a IShell environment. Returning the commands result. May throw CommandExceptions.
since 0.0.1
Implementation
@override
Future<ProcessResult> run(
String script, {
Map<String, String>? environment,
Stream<List<int>>? stdin,
StreamSink<List<int>>? stdout,
List<String>? args,
}) async {
_requireSingleCommand(script);
var cmd = buildCmdWithArgs(script, args);
_log.fine('Running: $cmd');
ProcessResult res;
try {
var result = await _prRun(
cmd,
verbose: _verbose,
environment: environment ?? _environment,
workingDirectory: _workingDirectory,
stdout: stdout,
stdin: stdin,
);
res = result.first;
} on pr.ShellException catch (ex) {
if (!_throwOnError && ex.result != null) {
res = ex.result!;
} else {
throw ChassisShellException(ex.message, ex.result, cmd);
}
}
return ProcessResult(
res.pid,
res.exitCode,
tryTrimRight(res.stdout),
tryTrimRight(res.stderr),
);
}