Skip to content

Commit 4023584

Browse files
LarsEckartisidore
andcommitted
! F IntelliJ Toolbox Windows
Co-Authored-By: Llewellyn Falco <[email protected]>
1 parent 50ee100 commit 4023584

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

approvaltests/src/main/java/org/approvaltests/reporters/DiffInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public static String[] getProgramFilesPaths()
6464
paths.add(System.getenv("ProgramFiles(x86)"));
6565
paths.add(System.getenv("ProgramFiles"));
6666
paths.add(System.getenv("ProgramW6432"));
67+
paths.add(System.getenv("LOCALAPPDATA") + "\\Programs");
6768
return paths.stream().filter(Objects::nonNull).toArray(String[]::new);
6869
}
6970
public static class One

approvaltests/src/main/java/org/approvaltests/reporters/IntelliJToolboxResolver.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public static DiffInfo findIt()
2323
if (!diffInfo.isEmpty())
2424
{ return diffInfo; }
2525
}
26+
DiffInfo diffInfo = getDiffInfoWindows(DiffInfo.getProgramFilesPaths(), f -> new File(f).exists());
27+
if (!diffInfo.isEmpty())
28+
{ return diffInfo; }
2629
return DiffInfo.getNull();
2730
}
2831
public static DiffInfo getDiffInfoMac(String userHome, Function1<String, Boolean> fileExists)
@@ -31,28 +34,26 @@ public static DiffInfo getDiffInfoMac(String userHome, Function1<String, Boolean
3134
"IntelliJ IDEA Community Edition");
3235
Queryable<String> applications = as("/Applications", userHome + "/Applications");
3336
String postfix = ".app/Contents/MacOS/idea";
34-
return getDiffInfo(fileExists, applications, locations, postfix);
37+
return getDiffInfo(fileExists, applications, locations, postfix, "/");
3538
}
3639
public static DiffInfo getDiffInfoLinux(String userHome, Function1<String, Boolean> fileExists)
3740
{
3841
Queryable<String> locations = as("intellij-idea-ultimate", "intellij-idea-community-edition");
3942
Queryable<String> applications = as(userHome + "/.local/share/JetBrains/Toolbox/apps");
4043
String postfix = "/bin/idea.sh";
41-
return getDiffInfo(fileExists, applications, locations, postfix);
42-
}
43-
private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations,
44-
Queryable<String> applications, String postfix)
45-
{
46-
Queryable<String> paths = locations.selectMany(a -> applications.select(l -> a + "/" + l + postfix));
47-
String matching = paths.first(fileExists);
48-
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
44+
return getDiffInfo(fileExists, applications, locations, postfix, "/");
4945
}
5046
public static DiffInfo getDiffInfoWindows(String[] programFiles, Function1<String, Boolean> fileExists) {
5147
Queryable<String> applications = as("IntelliJ IDEA Ultimate", "IntelliJ IDEA", "IntelliJ IDEA Community",
5248
"IntelliJ IDEA Community Edition");
5349
Queryable<String> locations = Queryable.as(programFiles);
5450
String postfix = "\\bin\\idea64.exe";
55-
Queryable<String> paths = locations.selectMany(l -> applications.select(a -> l + "\\" + a + postfix));
51+
return getDiffInfo(fileExists, locations, applications, postfix, "\\");
52+
}
53+
private static DiffInfo getDiffInfo(Function1<String, Boolean> fileExists, Queryable<String> locations,
54+
Queryable<String> applications, String postfix, String pathSeparator)
55+
{
56+
Queryable<String> paths = locations.selectMany(l -> applications.select(a -> l + pathSeparator + a + postfix));
5657
String matching = paths.first(fileExists);
5758
return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS);
5859
}

0 commit comments

Comments
 (0)