run method

  1. @override
Future<bool> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<bool> run() async {
  final bool fix = args['fix'];
  final List<FileRequirement> fsPaths = parent.globalFsPaths;

  List<bool> results = [];
  for (var fsp in fsPaths) {
    final name = path.basename(fsp.path);
    final closer = logger.printFixed('📂 Checking for $name', inRs);
    final file = File(fsp.path);
    bool exists = file.existsSync();
    String reason = '';
    if (!exists && fix && fsp.canCreate) {
      exists = fsp.creator!(file: file);
    } else {
      reason = 'can fix';
    }
    results.add(closer(exists, reason));
  }

  final result = results.every((r) => r);
  return result;
}