updateLauncherName method
void
updateLauncherName(
)
override
Implementation
@override
void updateLauncherName() {
if (!hasAllFiles(
[context.linuxCmakePath, context.linuxMyApplicationPath],
"Linux launcher name",
)) {
return;
}
final desiredName = common.fetchLauncherName(context);
final escapedDesiredName = common.escapeForDoubleQuotedString(desiredName);
final linuxCmakeData = common.readFile(context.linuxCmakePath);
final updatedLinuxCmakeData = common.replaceFirstMatchOrThrow(
linuxCmakeData,
RegExp(r'(set\(\s*BINARY_NAME\s*")([^"]*)("\s*\))'),
(match) => '${match.group(1)}$escapedDesiredName${match.group(3)}',
"BINARY_NAME in linux CMakeLists",
context.linuxCmakePath,
);
common.overwriteFile(context.linuxCmakePath, updatedLinuxCmakeData);
final linuxApplicationData =
common.readFile(context.linuxMyApplicationPath);
final updatedLinuxApplicationData = common.replaceAllMatchesOrThrow(
linuxApplicationData,
RegExp(
r'((?:gtk_header_bar_set_title|gtk_window_set_title)\s*\([^,]+,\s*")([^"]*)("\s*\)\s*;)',
),
(match) => '${match.group(1)}$escapedDesiredName${match.group(3)}',
"GTK window title",
context.linuxMyApplicationPath,
);
common.overwriteFile(
context.linuxMyApplicationPath,
updatedLinuxApplicationData,
);
}