updateLauncherName method

  1. @override
void updateLauncherName()
override

Implementation

@override
void updateLauncherName() {
  if (!hasAllFiles([context.macosAppInfoPath], "macOS launcher name")) {
    return;
  }

  final appInfoData = common.readFile(context.macosAppInfoPath);
  final desiredName = common.fetchLauncherName(context);
  final escapedDesiredName = common.escapeForSingleQuotedString(desiredName);

  final updatedAppInfoData = common.replaceFirstMatchOrThrow(
    appInfoData,
    RegExp(r'(^\s*PRODUCT_NAME\s*=\s*)(.+?)(\s*$)', multiLine: true),
    (match) => '${match.group(1)}$escapedDesiredName${match.group(3)}',
    "PRODUCT_NAME",
    context.macosAppInfoPath,
  );

  common.overwriteFile(context.macosAppInfoPath, updatedAppInfoData);
}