run method

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

Runs this command.

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

Implementation

@override
Future<void> run() async {
  final projectType = _detectProjectType();

  if (projectType == null) {
    stderr.writeln(
      'Unable to detect project type. Supported: Dart/Flutter, NPM, Ruby.',
    );
    exit(1);
  }

  switch (projectType) {
    case _ProjectType.flutter:
      await _runCommand('dart', [
        'fix',
        '--apply',
      ], description: 'Running dart fix --apply');
      break;

    case _ProjectType.dart:
      await _runCommand('dart', [
        'fix',
        '--apply',
      ], description: 'Running dart fix --apply');
      break;

    case _ProjectType.npm:
      await _runCommand('npm', [
        'audit',
        'fix',
      ], description: 'Running npm audit fix');
      break;

    case _ProjectType.ruby:
      await _runCommand('rubocop', [
        '-A',
      ], description: 'Running rubocop -A (auto-correct)');
      break;
  }
}