runScripts static method

Future<void> runScripts(
  1. List<String> commands,
  2. String workingDirectory,
  3. CommandLogger logger, {
  4. required String scriptType,
})

Implementation

static Future<void> runScripts(
  final List<String> commands,
  final String workingDirectory,
  final CommandLogger logger, {
  required final String scriptType,
}) async {
  if (commands.isEmpty) {
    return;
  }

  logger.info('Running $scriptType scripts', newParagraph: true);
  for (var i = 0; i < commands.length; i++) {
    final command = commands[i];

    logger.info(
      '(${i + 1}/${commands.length}) $command',
      newParagraph: i == 0,
    );

    try {
      await execute(
        command,
        stderr: stderr,
        stdout: stdout,
        workingDirectory: Directory(workingDirectory),
      );
    } on Exception catch (e, stackTrace) {
      throw ErrorExitException('$scriptType script failed', e, stackTrace);
    }
  }
}