runCommand function
Implementation
Future<List<ProcessResult>> runCommand(
String workingDirectory,
String command, {
bool verbose = true,
bool ignoreError = false,
StreamSink<List<int>>? stdout,
}) async {
logger.log('执行命令:[$workingDirectory] [$command]');
final shell = Shell(
workingDirectory: workingDirectory,
verbose: verbose,
stdout: stdout,
);
final results = await shell.run(command);
final errorTexts =
results.map((e) => e.errText).where((element) => element.isNotEmpty);
if (results.any((element) => element.exitCode != 0) && !ignoreError) {
logger.log(errorTexts.join('\n'), status: LogStatus.error);
exit(2);
}
logger.log('执行命令: $command 完成', status: LogStatus.success);
return results;
}