cloneRepo function

void cloneRepo({
  1. required String repo,
  2. required Directory workingDir,
  3. String? outDirName,
})

Clone a git repo

Implementation

void cloneRepo({
  required String repo,
  required Directory workingDir,
  String? outDirName,
}) {
  final path = workingDir.absolute.path;
  print('(p)Cloning into $path');
  final targetPath = workingDir.absolute.path;
  if (outDirName == null) {
    print('(p)Cloning into $targetPath');
  } else {
    print('(p)Cloning into $targetPath/$outDirName');
  }
  final args = ['clone', repo];
  if (outDirName != null && outDirName.isNotEmpty) {
    args.add(outDirName);
  }
  runProcessSync(
    executable: 'git',
    arguments: args,
    workingDir: workingDir.absolute.path,
    throwingError:
        'Error cloning repo $repo into working directory $targetPath',
  );
}