jeansaad / chalet

🏩 A simple process manager for developers. Start apps from your browser and access them using local domains
MIT License
156 stars 19 forks source link

Bug: `run` command removes saved servers (without --force) #32

Open svicalifornia opened 2 years ago

svicalifornia commented 2 years ago

If there is already a saved server config for myapp, and a user runs the run command for another server named myapp, chalet will correctly report the name conflict:

Configuration already exists with name 'fp2' (use -f to force creation)

However, it then proceeds to run the specified command anyway, and when that command exits, it proceeds to remove the config file for the previously saved myapp server β€” thereby removing the myapp server from chalet.

This result is very destructive and unexpected β€” especially since chalet is already detecting the name collision. A previously saved server should never be modified or removed by the run command unless the --force option is given.

Even worse, this can happen even if the run command does not specify a -n/--name option β€” because it will use the current directory name as the default server name and will proceed to remove any saved server matching that name.

Unless the --force option is given, then there currently is no clean way to run a server (specified or derived from cwd) with the same name as an existing server, since the run command currently works by writing to a temporary config file (and thus would overwrite the existing server's config file). Therefore, if such a name collision is detected, then the run command should display the name-collision error message (as shown above) and then exit immediately.