updateLauncherName method

  1. @override
void updateLauncherName()
override

Implementation

@override
void updateLauncherName() {
  for (var command in _commands) {
    common.logInfo("Running rename command for ${command.dir}");
    final normalizedPath = command.dirPath
        .replaceAll("/", Platform.pathSeparator)
        .replaceAll(r"\", Platform.pathSeparator);
    final segments = normalizedPath.split(Platform.pathSeparator);
    final markerIndex =
        segments.lastIndexWhere((segment) => segment == command.dir);
    if (markerIndex < 0) {
      common.logSkipped(
        "${command.dir} command",
        command.dirPath,
        "command directory marker not found in path",
      );
      continue;
    }

    final directoryPath =
        segments.take(markerIndex + 1).join(Platform.pathSeparator);
    if (!Directory(directoryPath).existsSync()) {
      common.logSkipped(
        "${command.dir} command",
        directoryPath,
        "platform directory does not exist",
      );
      continue;
    }

    try {
      command.updateLauncherName();
      common.logInfo("Completed rename command for ${command.dir}");
    } catch (e) {
      common.logError(
        "${command.dir} command",
        command.dirPath,
        e.toString(),
      );
    }
  }
}