getGitHooksDir method

Directory getGitHooksDir(
  1. Directory projectDir
)

Parse the git hooks directory argument

Implementation

Directory getGitHooksDir(final Directory projectDir) {
  final Directory hooksDir = Directory(
    '${projectDir.path}/${ScriptConfig.hooksDirName}',
  );

  try {
    if (hooksDir.existsSync()) {
      hooksDir.deleteSync(recursive: true);
    }
    hooksDir.createSync();
  } on Exception catch (exception) {
    throw UnrecoverableException(
      'git hooks dir could not be created.\n'
      'System error: ${exception.toString()}',
      exitUnexpectedError,
    );
  }

  return hooksDir;
}