deleteOldDirectories function

Future<void> deleteOldDirectories(
  1. String lang,
  2. String oldPackage,
  3. String basePath
)

Implementation

Future<void> deleteOldDirectories(
    String lang, String oldPackage, String basePath) async {
  var dirList = oldPackage.split('.');
  var reversed = dirList.reversed.toList();

  for (int i = 0; i < reversed.length; i++) {
    String path = '$basePath$lang/' + dirList.join('/');

    if (Directory(path).listSync().toList().isEmpty) {
      Directory(path).deleteSync();
    }
    dirList.removeLast();
  }
}