mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 09:40:35 +13:00
Determine vscode installation directory on windows from Path
This commit is contained in:
parent
b3f299dbe6
commit
2e54c9368d
1 changed files with 19 additions and 0 deletions
|
@ -1,9 +1,12 @@
|
|||
package io.xpipe.app.prefs;
|
||||
|
||||
import io.xpipe.app.ext.PrefsChoiceValue;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.util.ApplicationHelper;
|
||||
import io.xpipe.app.util.WindowsRegistry;
|
||||
import io.xpipe.core.impl.LocalStore;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -30,6 +33,22 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
|||
|
||||
@Override
|
||||
protected Optional<Path> determinePath() {
|
||||
// Try to locate if it is in the Path
|
||||
try (var cc = LocalStore.getShell()
|
||||
.command(ShellDialects.getPlatformDefault().getWhichCommand("code.cmd"))
|
||||
.start()) {
|
||||
var out = cc.readStdoutDiscardErr();
|
||||
var exit = cc.getExitCode();
|
||||
if (exit == 0) {
|
||||
var first = out.lines().findFirst();
|
||||
if (first.isPresent()) {
|
||||
return first.map(Path::of);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).omit().handle();
|
||||
}
|
||||
|
||||
return Optional.of(Path.of(System.getenv("LOCALAPPDATA"))
|
||||
.resolve("Programs")
|
||||
.resolve("Microsoft VS Code")
|
||||
|
|
Loading…
Reference in a new issue