Skip to content

Commit c3924fa

Browse files
committed
Determine base directory in a more reliable manner
1 parent d391553 commit c3924fa

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

pass-winmenu-tests/Configuration/RuntimeConfigurationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace PassWinmenuTests.Configuration
77
public class RuntimeConfigurationTests
88
{
99
[Fact]
10-
public void Parse_NoArgs_ConfigFileLocationIsNull()
10+
public void Parse_NoArgs_SetsDefaultLocation()
1111
{
1212
var config = RuntimeConfiguration.Parse(new[] { "app.exe" });
1313

14-
config.ConfigFileLocation.ShouldBeNull();
14+
config.ConfigFileLocation.ShouldEndWith("pass-winmenu.yaml");
1515
}
1616

1717
[Fact]

pass-winmenu/src/Configuration/RuntimeConfiguration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
using System;
12
using System.IO;
2-
using System.Reflection;
33

44
#nullable enable
55
namespace PassWinmenu.Configuration
@@ -14,8 +14,8 @@ private RuntimeConfiguration()
1414

1515
internal static RuntimeConfiguration Parse(string[] args)
1616
{
17-
var executableDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location);
18-
var defaultConfigPath = Path.Combine(executableDirectory!, "pass-winmenu.yaml");
17+
var executableDirectory = AppDomain.CurrentDomain.BaseDirectory;
18+
var defaultConfigPath = Path.Combine(executableDirectory, "pass-winmenu.yaml");
1919

2020
var configuration = new RuntimeConfiguration
2121
{

pass-winmenu/src/Dependencies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void LoadConfigFile(RuntimeConfiguration runtimeConfig)
250250
"Would you like to open it now?", "New configuration file created", MessageBoxButton.YesNo);
251251
if (open == MessageBoxResult.Yes)
252252
{
253-
Process.Start(runtimeConfig.ConfigFileLocation);
253+
Process.Start("explorer", runtimeConfig.ConfigFileLocation);
254254
}
255255

256256
App.Exit();
@@ -262,7 +262,7 @@ private void LoadConfigFile(RuntimeConfiguration runtimeConfig)
262262
"Would you like to open both files now?", "Configuration file out of date", MessageBoxButton.YesNo);
263263
if (openBoth == MessageBoxResult.Yes)
264264
{
265-
Process.Start(runtimeConfig.ConfigFileLocation);
265+
Process.Start("explorer", runtimeConfig.ConfigFileLocation);
266266
Process.Start(backedUpFile);
267267
}
268268
App.Exit();

pass-winmenu/src/ExternalPrograms/Gpg/GpgHomeDirResolver.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ public GpgHomeDirectory GetHomeDir()
4545
/// </summary>
4646
private string GetDefaultHomeDir()
4747
{
48-
var psi = new ProcessStartInfo(installation.GpgConfExecutable.FullName, "--list-dirs");
48+
var psi = new ProcessStartInfo(installation.GpgConfExecutable.FullName, "--list-dirs")
49+
{
50+
RedirectStandardOutput = true,
51+
UseShellExecute = false,
52+
};
53+
4954
var gpgConf = processes.Start(psi);
5055

5156
var lines = gpgConf.StandardOutput.ReadAllLines();

0 commit comments

Comments
 (0)