runScripts static method
Implementation
static Future<void> runScripts(
final List<String> commands,
final String workingDirectory,
final CommandLogger logger, {
required final String scriptType,
final int padHeadingRight = 0,
final IOSink? stdout,
final IOSink? stderr,
}) async {
if (commands.isEmpty) {
return;
}
logger.info('Running $scriptType scripts:', newParagraph: true);
for (var i = 0; i < commands.length; i++) {
final command = commands[i];
int exitCode;
try {
exitCode = await _runScript(
command,
heading: '(${i + 1}/${commands.length}) $command'.padRight(
padHeadingRight,
),
workingDirectory: workingDirectory,
logger: logger,
stdout: stdout,
stderr: stderr,
);
} on Exception catch (e, stackTrace) {
throw ErrorExitException(
'$scriptType script failed: "$command"',
e,
stackTrace,
);
}
if (exitCode != 0) {
throw ErrorExitException(
'$scriptType script failed with exit code $exitCode: "$command"',
);
}
}
}