From 1fe086d53e0b239a06d542b645295cd776b5fa1f Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Tue, 14 Jun 2022 22:48:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Move=20legacy=20.phpmon.conf.jso?= =?UTF-8?q?n=20to=20new=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Preferences/Preferences.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpmon/Domain/Preferences/Preferences.swift b/phpmon/Domain/Preferences/Preferences.swift index 1071892..58816bc 100644 --- a/phpmon/Domain/Preferences/Preferences.swift +++ b/phpmon/Domain/Preferences/Preferences.swift @@ -211,6 +211,7 @@ class Preferences { // MARK: - Custom Preferences private func loadCustomPreferences() { + moveOutdatedConfigurationFile() let url = URL(fileURLWithPath: "/Users/\(Paths.whoami)/.config/phpmon/config.json") if Filesystem.fileExists(url.path) { Log.info("A custom ~/.config/phpmon/config.json file was found. Attempting to parse...") @@ -220,6 +221,15 @@ class Preferences { } } + private func moveOutdatedConfigurationFile() { + if Filesystem.fileExists("~/.phpmon.conf.json") && !Filesystem.fileExists("~/.config/phpmon/config.json") { + Log.info("An outdated configuration file was found. Moving it...") + Shell.run("mkdir -p ~/.config/phpmon") + Shell.run("mv ~/.phpmon.conf.json ~/.config/phpmon/config.json") + Log.info("The configuration file was moved successfully!") + } + } + private func loadCustomPreferencesFile(_ url: URL) { do { customPreferences = try JSONDecoder().decode(