validateConfig method

void validateConfig(
  1. OperatingSystem currentOs,
  2. String currentDirPath,
  3. String hooksDirPath
)

Validate script configuration.

currentDirPath represent the current project directory path. hooksDirPath represent the current project hooks directory path.

Throws UnrecoverableException if one or some of the directory does not match the current project's script configuration.

Implementation

void validateConfig(
  final OperatingSystem currentOs,
  final String currentDirPath,
  final String hooksDirPath,
) {
  if (currentDirPath != projectDir.path) {
    throw UnrecoverableException(
      'Current directory $currentDirPath is different than '
      '${projectDir.path}\nPlease run setup tool',
      ExitCode.config.code,
    );
  }

  if (hooksDirPath != hooksDir.path) {
    throw UnrecoverableException(
      'Current hooks directory $hooksDirPath is different than '
      '${hooksDir.path}\nPlease run setup tool',
      ExitCode.config.code,
    );
  }

  if (currentOs.name() != operatingSystem) {
    throw UnrecoverableException(
      'Script was configured on $operatingSystem but now the project is run '
      'on  ${currentOs.name()}\nPlease run setup tool',
      ExitCode.config.code,
    );
  }
}