runSync function
List<ProcessResult>
runSync(
- String script, {
- bool throwOnError = true,
- String? workingDirectory,
- Map<
String, String> ? environment, - bool includeParentEnvironment = true,
- bool? runInShell,
- Encoding stdoutEncoding = systemEncoding,
- Encoding stderrEncoding = systemEncoding,
- StreamSink<
List< ? stdout,int> > - StreamSink<
List< ? stderr,int> > - bool verbose = true,
- bool? commandVerbose,
- bool? commentVerbose,
- ShellOptions? options,
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.
runSync('flutter build');
runSync('dart --version');
runSync('''
dart --version
git status
''');
Compared to the async version, it is not possible to kill the spawn process nor to feed any input.
Implementation
List<ProcessResult> runSync(
String script, {
bool throwOnError = true,
String? workingDirectory,
Map<String, String>? environment,
bool includeParentEnvironment = true,
bool? runInShell,
Encoding stdoutEncoding = systemEncoding,
Encoding stderrEncoding = systemEncoding,
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,
/// Override all other options parameters
ShellOptions? options,
}) {
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)
.runSync(script);
}