From 29c8fcbde2592b01aca5df2d9ccdac5caf1de2db Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 29 Jan 2022 00:11:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Force=20composer=20from=20/usr/l?= =?UTF-8?q?ocal/bin=20(#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Core/Base.lproj/Main.storyboard | 2 +- phpmon/Domain/Menu/MainMenu.swift | 18 ++++++++++++------ phpmon/Localizable.strings | 3 +++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/phpmon/Domain/Core/Base.lproj/Main.storyboard b/phpmon/Domain/Core/Base.lproj/Main.storyboard index e1c35ad..e1169a3 100644 --- a/phpmon/Domain/Core/Base.lproj/Main.storyboard +++ b/phpmon/Domain/Core/Base.lproj/Main.storyboard @@ -786,7 +786,7 @@ Gw - + diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index b515d4a..88734bc 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -359,6 +359,14 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { */ private func updateGlobalDependencies(notify: Bool, completion: @escaping (Bool) -> Void) { + if !Shell.fileExists("/usr/local/bin/composer") { + Alert.notify( + message: "alert.composer_missing.title".localized, + info: "alert.composer_missing.info".localized + ) + return + } + PhpEnv.shared.isBusy = true setBusyImage() self.rebuild() @@ -378,14 +386,12 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { window?.setType(info: true) DispatchQueue.global(qos: .userInitiated).async { - let output = Shell.user.executeSynchronously( - "composer global update", requiresPath: true + let task = Shell.user.createTask( + for: "/usr/local/bin/composer global update", requiresPath: true ) - let task = Shell.user.createTask(for: "composer global update", requiresPath: true) - DispatchQueue.main.async { - window?.addToConsole("composer global update\n") + window?.addToConsole("/usr/local/bin/composer global update\n") } Shell.captureOutput( @@ -409,7 +415,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { Shell.haltCapturingOutput(task) DispatchQueue.main.async { - if output.task.terminationStatus <= 0 { + if task.terminationStatus <= 0 { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { window?.close() if (notify) { diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 5763c5a..9eeca45 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -169,6 +169,9 @@ // ALERTS // Composer Update +"alert.composer_missing.title" = "Composer not found!"; +"alert.composer_missing.info" = "Make sure you have Composer available in `/usr/local/bin/composer`. If Composer is located somewhere else, please create a symlink, like so (make sure to use the correct path):\n\n`ln -s /path/to/composer /user/local/bin`."; + "alert.composer_progress.title" = "Updating global dependencies..."; "alert.composer_progress.info" = "You can see the progress in the terminal output below.";