outputs method

Future<int> outputs(
  1. Iterable<String> directories
)

Implementation

Future<int> outputs(Iterable<String> directories) async {
  var failed = false;
  for (final raw in directories.toSet()) {
    try {
      final directory = _safeOutput(raw);
      if (!directory.existsSync()) {
        logger.logDebug('output already clean: ${directory.path}');
        continue;
      }
      logger.logInfo(
        '${dryRun ? '[dry-run] would remove' : 'removing'} ${directory.path}',
      );
      if (!dryRun) {
        await directory.delete(recursive: true);
      }
    } on FileSystemException catch (error) {
      failed = true;
      logger.logError('Could not clean $raw: ${error.message}');
    } on ArgumentError catch (error) {
      failed = true;
      logger.logError(error.message.toString());
    }
  }
  return failed ? 1 : 0;
}