transferPackageConfig static method

Future transferPackageConfig({
  1. required String fromPackage,
  2. required String toPackage,
  3. required StdoutSession stdoutSession,
  4. ({String newPackageName, String oldPackageName})? packageNameReplacementInfo,
})

Implementation

static Future transferPackageConfig({
  required String fromPackage,
  required String toPackage,
  required StdoutSession stdoutSession,
  ({
    String oldPackageName,
    String newPackageName
  })? packageNameReplacementInfo,
}) async {
  final fromPackageConfigPath = getPackageConfigPathForPackage(fromPackage,
      stdoutSession: stdoutSession, doCheckWorkspace: true);
  final toPackageConfigPath = getPackageConfigPathForPackage(toPackage,
      stdoutSession: stdoutSession, doCheckWorkspace: true);
  Directory(path.dirname(toPackageConfigPath)).createSync(recursive: true);
  File(toPackageConfigPath)
      .writeAsStringSync(File(fromPackageConfigPath).readAsStringSync());
  await _adaptPackageConfigToAbsolutePaths(
    targetPackageConfigPath: toPackageConfigPath,
    sourcePackageConfigPath: fromPackageConfigPath,
    packageNameReplacementInfo: packageNameReplacementInfo,
  );
}