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 closer = logger.printFixed("   👀 Checking git status");
  final args = ['status', '--porcelain'];
  final gitResult = Process.runSync('git', args, workingDirectory: rootDir);
  final exitCode = gitResult.exitCode;
  final stdout = gitResult.stdout.toString();
  final result = exitCode == 0 && stdout.isEmpty;

  return closer(
    result,
    !result ? 'Not a git directory, or not a clean working tree.' : '',
  );
}