mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 15:10:23 +00:00
Improve homebrew check
This commit is contained in:
parent
b5a030e615
commit
9b20fe7e8e
1 changed files with 8 additions and 5 deletions
|
@ -2,21 +2,23 @@ package io.xpipe.app.core.check;
|
|||
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.store.FileNames;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AppHomebrewCoreutilsCheck {
|
||||
|
||||
public static boolean hasCoreutils() {
|
||||
public static Optional<String> checkCoreutils() {
|
||||
var fc = new ProcessBuilder("which", "stat").redirectErrorStream(true);
|
||||
try {
|
||||
var proc = fc.start();
|
||||
var out = new String(proc.getInputStream().readAllBytes());
|
||||
proc.waitFor(1, TimeUnit.SECONDS);
|
||||
var first = out.lines().findFirst();
|
||||
return first.map(s -> s.contains("coreutils")).orElse(false);
|
||||
return first.filter(s -> s.contains("coreutils")).map(s -> FileNames.getParent(s));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +27,9 @@ public class AppHomebrewCoreutilsCheck {
|
|||
return;
|
||||
}
|
||||
|
||||
if (hasCoreutils()) {
|
||||
ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH." +
|
||||
var loc = checkCoreutils();
|
||||
if (loc.isPresent()) {
|
||||
ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH at " + loc.get() + "." +
|
||||
" The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects." +
|
||||
" Please remove the coreutils commands from your PATH prior to launching XPipe.")
|
||||
.term()
|
||||
|
|
Loading…
Reference in a new issue