feat: update executable perms on linux/macos

This commit is contained in:
Patrick Erichsen 2025-05-08 19:04:53 -07:00
parent 22f6fdfa1b
commit dcbd80ecf4
3 changed files with 31 additions and 17 deletions

View file

@ -49,6 +49,21 @@ class IntelliJIDE(
private val ripgrep: String = getRipgrepPath()
init {
try {
val os = getOS()
if (os == OS.LINUX || os == OS.MAC) {
val file = File(ripgrep)
if (!file.canExecute()) {
file.setExecutable(true)
}
}
} catch (e: Throwable) {
e.printStackTrace()
}
}
/**
* Updates the timestamp when a file is saved
*/

View file

@ -27,7 +27,7 @@ fun getContinuePluginPath(): Path {
fun getContinueCorePath(): String {
val pluginPath = getContinuePluginPath()
val corePath = Paths.get(pluginPath.toString(), "core").toString()
val (_, _, target) = getOsAndArch()
val target = getOsAndArchTarget()
return Paths.get(corePath, target).toString()
}
@ -39,8 +39,9 @@ fun getContinueCorePath(): String {
*/
fun getContinueBinaryPath(): String {
val targetPath = getContinueCorePath()
val (os, _, _) = getOsAndArch()
return Paths.get(targetPath, "continue-binary" + (if (os == "win32") ".exe" else "")).toString()
val os = getOS()
val exeSuffix = if (os == OS.WINDOWS) ".exe" else ""
return Paths.get(targetPath, "continue-binary$exeSuffix").toString()
}
/**
@ -51,6 +52,7 @@ fun getContinueBinaryPath(): String {
*/
fun getRipgrepPath(): String {
val targetPath = getContinueCorePath()
val (os, _, _) = getOsAndArch()
return Paths.get(targetPath, "rg" + (if (os == "win32") ".exe" else "")).toString()
val os = getOS()
val exeSuffix = if (os == OS.WINDOWS) ".exe" else ""
return Paths.get(targetPath, "rg$exeSuffix").toString()
}

View file

@ -94,20 +94,19 @@ fun Any?.getNestedOrNull(vararg keys: String): Any? {
}
/**
* Get the OS and architecture as a string pair formatted for Continue binary.
* Get the target string for Continue binary.
* The format is "$os-$arch" where:
* - os is one of: darwin, win32, or linux
* - arch is one of: arm64 or x64
*
* @return Triple of OS string, architecture string, and combined target string
* @return Target string in format "$os-$arch"
*/
fun getOsAndArch(): Triple<String, String, String> {
val osName = System.getProperty("os.name").lowercase()
val os = when {
osName.contains("mac") || osName.contains("darwin") -> "darwin"
osName.contains("win") -> "win32"
osName.contains("nix") || osName.contains("nux") || osName.contains("aix") -> "linux"
else -> "linux"
fun getOsAndArchTarget(): String {
val os = getOS()
val osStr = when (os) {
OS.MAC -> "darwin"
OS.WINDOWS -> "win32"
OS.LINUX -> "linux"
}
val osArch = System.getProperty("os.arch").lowercase()
@ -117,7 +116,5 @@ fun getOsAndArch(): Triple<String, String, String> {
else -> "x64"
}
val target = "$os-$arch"
return Triple(os, arch, target)
return "$osStr-$arch"
}