run function
Future<List<ProcessResult> >
run(
- String script, {
- bool throwOnError = true,
- String? workingDirectory,
- Map<
String, String> ? environment, - bool includeParentEnvironment = true,
- bool? runInShell,
- Encoding stdoutEncoding = systemEncoding,
- Encoding stderrEncoding = systemEncoding,
- Stream<
List< ? stdin,int> > - StreamSink<
List< ? stdout,int> > - StreamSink<
List< ? stderr,int> > - bool verbose = true,
- bool? commandVerbose,
- bool? commentVerbose,
- ShellOptions? options,
- void onProcess(
- Process process
Run one or multiple plain text command(s).
Commands can be split by line.
Commands can be on multiple line if ending with ^
or \
.
Returns a list of executed command line results. Verbose by default.
Prefer using options
than the parameters. options
overrides all other
parameters but onProcess
.
await run('flutter build');
await run('dart --version');
await run('''
dart --version
git status
''');
Implementation
Future<List<ProcessResult>> run(
String script, {
bool throwOnError = true,
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool? runInShell,
Encoding stdoutEncoding = systemEncoding,
Encoding stderrEncoding = systemEncoding,
Stream<List<int>>? stdin,
StreamSink<List<int>>? stdout,
StreamSink<List<int>>? stderr,
bool verbose = true,
// Default to true
bool? commandVerbose,
// Default to true if verbose is true
bool? commentVerbose,
ShellOptions? options,
void Function(Process process)? onProcess,
}) {
return Shell(
throwOnError: throwOnError,
workingDirectory: workingDirectory,
environment: environment,
includeParentEnvironment: includeParentEnvironment,
runInShell: runInShell,
stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding,
stdin: stdin,
stdout: stdout,
stderr: stderr,
verbose: verbose,
commandVerbose: commandVerbose,
commentVerbose: commentVerbose,
options: options)
.run(script, onProcess: onProcess);
}