Fixed wrong path when opening terminal in macos

This commit is contained in:
Abdelilah El Aissaoui 2023-05-03 15:02:58 +02:00
parent 7df6381813
commit abec077f23
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
2 changed files with 4 additions and 5 deletions

View File

@ -4,7 +4,6 @@ package com.jetpackduba.gitnuro.terminal
import com.jetpackduba.gitnuro.managers.IShellManager
import javax.inject.Inject
// TODO Test this on MacOS
class MacTerminalProvider @Inject constructor(
private val shellManager: IShellManager
) : ITerminalProvider {
@ -15,12 +14,11 @@ class MacTerminalProvider @Inject constructor(
}
override fun isTerminalInstalled(terminalEmulator: TerminalEmulator): Boolean {
val checkTerminalInstalled = shellManager.runCommand(listOf("which", terminalEmulator.path, "2>/dev/null"))
return !checkTerminalInstalled.isNullOrEmpty()
return true // TODO Return true always until we support multiple terminals
}
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
shellManager.runCommandInPath(listOf("open", "-a", terminalEmulator.path), repositoryPath)
// TODO Check if passing the path as argument is required for other terminal emulators
shellManager.runCommandInPath(listOf("open", "-a", terminalEmulator.path, "--args", repositoryPath), repositoryPath)
}
}

View File

@ -8,6 +8,7 @@ class WindowsTerminalProvider @Inject constructor(
) : ITerminalProvider {
override fun getTerminalEmulators(): List<TerminalEmulator> {
return listOf(
// TODO powershell is the only terminal emulator supported until we add support for custom
TerminalEmulator("Powershell", "powershell.exe"),
)
}