execute method

  1. @override
Future<void> execute()
override

Implementation

@override
Future<void> execute() async {
  final backupDir = Directory('.rebrand_backup');
  if (backupDir.existsSync()) {
    backupDir.deleteSync(recursive: true);
  }
  backupDir.createSync();

  print("   📂 Backing up native configurations...");

  final targets = ['pubspec.yaml', 'android', 'ios'];

  for (var target in targets) {
    final targetExists =
        await FileSystemEntity.type(target) != FileSystemEntityType.notFound;
    if (!targetExists) {
      print('Skipping backup of $target as it does not exist.');
      continue;
    }

    if (await FileSystemEntity.isDirectory(target)) {
      await _copyDirectory(
        Directory(target),
        Directory(p.join(backupDir.path, target)),
      );
    } else if (await FileSystemEntity.isFile(target)) {
      await File(target).copy(p.join(backupDir.path, target));
    }
  }
}