Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions commands/coldbox/reinit.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ component aliases="fwreinit" {

/**
* @password The FWReinit password
* @name Name of the CommandBox server to reinit
* @name Name of the CommandBox server to reinit, will default to the name listed in server.json file
* @showUrl Show the Url to reinit
**/
function run(
password = "1",
name = "",
name = getDefaultServerName(),
showUrl = true
){
var serverInfo = serverService.getServerInfoByDiscovery( getCWD(), arguments.name );
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );

if ( !structCount( serverInfo ) ) {
Comment on lines +29 to 31
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to name-only discovery means coldbox reinit can no longer fall back to discovering the running server by the current working directory. If getDefaultServerName() returns an empty string (e.g., no server.json in the CWD or the server isn’t registered), getServerInfoByDiscovery( name = "" ) will likely return no match where the previous CWD-based discovery would have succeeded. Consider adding a fallback: if arguments.name is blank (or the name lookup returns an empty struct), attempt discovery using the CWD (or the server.json path) before failing.

Suggested change
var serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
if ( !structCount( serverInfo ) ) {
var serverInfo = {};
// Try name-based discovery first if we have a non-blank name
if ( len( trim( arguments.name ) ) ) {
serverInfo = serverService.getServerInfoByDiscovery( name = arguments.name );
}
// Fallback: attempt discovery using the server.json in the current working directory
if ( !structCount( serverInfo ) ) {
serverInfo = serverService.getServerInfoByDiscovery( serverConfigFile = "server.json" );
}
if ( !structCount( serverInfo ) ) {

Copilot uses AI. Check for mistakes.
print.boldRedLine(
"No server configurations found for '#getCWD()#', so have no clue what to reinit buddy!"
"No server configurations found for '#getCWD()#' and '#arguments.name#', so have no clue what to reinit buddy!"
);
} else {
var thisURL = "#serverInfo.host#:#serverInfo.port#/?fwreinit=#arguments.password#";
Expand All @@ -50,4 +50,9 @@ component aliases="fwreinit" {
}
}

private function getDefaultServerName(){
var serverInfo = serverService.getServerInfoByDiscovery( serverConfigFile = "server.json" );
return serverInfo.keyExists( "name" ) ? serverInfo.name : "";
}

}
Loading