Skip to content

Commit

Permalink
Prevent overwriting of server config
Browse files Browse the repository at this point in the history
  • Loading branch information
sebduggan committed Feb 6, 2024
1 parent 5648355 commit be484eb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions commands/preside/start.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 = "";

Expand Down

0 comments on commit be484eb

Please sign in to comment.