getDirFromCliPackage static method

String getDirFromCliPackage(
  1. {required String sourceFolderPath}
)

Pass path after feature

Implementation

static String getDirFromCliPackage({
  required String sourceFolderPath,
}) {
  String dependencyName = Utility.getPackageNameAndVersion();
  String dependencyPath = PathHandler().getDependencyPath();
  if (!Directory(dependencyPath).existsSync()) {
    Utility.errorPrinter(
        text: 'Dependency $dependencyName not found in .pub-cache directory');
    exit(1);
  }
  String dependencyLibPath = path.join(dependencyPath, 'lib');
  if (!Directory(dependencyLibPath).existsSync()) {
    Utility.errorPrinter(
        text: 'Dependency $dependencyName does not contain a lib folder');
    exit(1);
  }
  String localSourceFolderPath =
      '$dependencyLibPath$kFeature$sourceFolderPath';
  Utility.grantPermissions(folderPath: localSourceFolderPath);

  if (!Directory(localSourceFolderPath).existsSync()) {
    Utility.errorPrinter(
        text: '$kError $localSourceFolderPath folder does not exist');
    exit(1);
  }
  return localSourceFolderPath;
}