From be484eba508a6f7760cea8ef07304eb3d0e4b1e5 Mon Sep 17 00:00:00 2001 From: Seb Duggan Date: Tue, 6 Feb 2024 16:30:48 +0000 Subject: [PATCH] Prevent overwriting of server config --- commands/preside/start.cfc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/commands/preside/start.cfc b/commands/preside/start.cfc index 6e8f921..25e5841 100644 --- a/commands/preside/start.cfc +++ b/commands/preside/start.cfc @@ -45,8 +45,12 @@ component { serverProps.rewritesEnable = true; serverProps.rewritesConfig = serverProps.rewritesConfig ?: ( serverProps.directory & "/urlrewrite.xml" ); - if ( !serverProps.keyExists( "trayIcon" ) ) { - if ( osInfo['os.name'].findNoCase( "Mac OS" ) || osInfo['os.name'].findNoCase( "Linux" ) ) { + var serverConfig = getServerConfig( arguments.directory, arguments.serverConfigFile ); + if ( Len( serverConfig?.trayIcon ) && !StructKeyExists( serverProps, "trayIcon" ) ) { + serverProps.trayIcon = serverConfig.trayIcon; + } + if ( !StructKeyExists( serverProps, "trayIcon" ) ) { + if ( FindNoCase( osInfo['os.name'], "Mac OS" ) || FindNoCase( osInfo['os.name'], "Linux" ) ) { serverProps.trayIcon = resourceDir & "/trayicon_hires.png"; } else { serverProps.trayIcon = resourceDir & "/trayicon.png"; @@ -119,12 +123,17 @@ component { print.line( "Checks complete. Starting your server now..." ).toConsole(); } - private string function _getCfConfigFilePath() { + private struct function getServerConfig( required string directory, required string serverConfigFile ) { var serverConfPath = arguments.directory & arguments.serverConfigFile; if ( !FileExists( serverConfPath ) ) { FileWrite( serverConfPath, formatterUtil.formatJson( { "web"={ "webroot"=arguments.directory }} ) ); } - var serverConf = SerializeJson( FileRead( serverConfPath ) ); + + return DeserializeJson( FileRead( serverConfPath ) ); + } + + private string function _getCfConfigFilePath() { + var serverConfig = getServerConfig( arguments.directory, arguments.serverConfigFile ); var possibleKeys = [ "file", "server", "web" ]; var relFilePath = "";