resolveDirectory method

Directory resolveDirectory(
  1. ProjectDirectory reference,
  2. Directory? candidate
)

Resolves a declared working directory against this run's scope.

Implementation

Directory resolveDirectory(ProjectDirectory reference, Directory? candidate) {
  switch (reference.kind) {
    case ProjectDirectoryKind.candidate:
      final staged = candidate;
      if (staged == null) {
        throw const FormatException('project_operation_candidate_required');
      }
      return staged;
    case ProjectDirectoryKind.project:
      return workspace;
    case ProjectDirectoryKind.external:
      final path = reference.path;
      if (path == null || !p.isAbsolute(path)) {
        throw const FormatException(
          'project_operation_absolute_path_required',
        );
      }
      return Directory(path);
  }
}