From 13a63507caad76da626f1f27f923c8997f255d06 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sun, 19 Oct 2025 16:46:14 +0200 Subject: [PATCH 1/4] fixes file path --- private/Alias-Helper.ps1 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/private/Alias-Helper.ps1 b/private/Alias-Helper.ps1 index 661b2da..fa7a638 100644 --- a/private/Alias-Helper.ps1 +++ b/private/Alias-Helper.ps1 @@ -1,12 +1,18 @@ . $PSScriptRoot\..\classes\AliasPathMapping.ps1 function Get-Script-Path { - $moduleName = "quickpath" - $modulePath = (Get-Module -Name $moduleName -ListAvailable | Select-Object -First 1 -ExpandProperty Path) - $rootPath = Split-Path $modulePath -Parent - $rootPath = Split-Path $rootPath -Parent - - "$rootPath\aliases.json" + $appData = Join-Path $env:LOCALAPPDATA 'quickpath' + if (-not (Test-Path $appData)) { + New-Item -Path $appData -ItemType Directory -Force | Out-Null + } + + $file = Join-Path $appData 'aliases.json' + + if (-not (Test-Path $file)) { + '[]' | New-Item -Path $file -ItemType File -Force | Out-Null + } + + return $file } From 26de8ab4dddc1a924223962275fce23d2d1553b1 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sun, 19 Oct 2025 16:50:30 +0200 Subject: [PATCH 2/4] fixes aliases file path --- quickpath.psd1 | 2 +- tests/Alias-Helper.Tests.ps1 | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/quickpath.psd1 b/quickpath.psd1 index 8045e98..18621b3 100644 --- a/quickpath.psd1 +++ b/quickpath.psd1 @@ -12,7 +12,7 @@ RootModule = 'quickpath.psm1' # Version number of this module. - ModuleVersion = '0.0.0' + ModuleVersion = '0.0.2' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/tests/Alias-Helper.Tests.ps1 b/tests/Alias-Helper.Tests.ps1 index 2a11819..3d89e74 100644 --- a/tests/Alias-Helper.Tests.ps1 +++ b/tests/Alias-Helper.Tests.ps1 @@ -62,10 +62,9 @@ Describe 'Alias-Helper' { } context 'Get-Script-Path' { It 'Returns correct path' { - Mock Get-Module { @{Path = "moduleinstallfolder/moduleversion/modulepath" } } - + Get-Script-Path - | Should -Be "moduleinstallfolder\aliases.json" + | Should -Be "$env:LOCALAPPDATA\quickpath\aliases.json" } } context 'Get-Alias' { From a73088246c1d3f51a046d6c0bb679a5c49539042 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sun, 19 Oct 2025 17:00:56 +0200 Subject: [PATCH 3/4] fixes aliases file path --- quickpath.psd1 | 2 +- tests/Alias-Helper.Tests.ps1 | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/quickpath.psd1 b/quickpath.psd1 index 18621b3..35bffdf 100644 --- a/quickpath.psd1 +++ b/quickpath.psd1 @@ -12,7 +12,7 @@ RootModule = 'quickpath.psm1' # Version number of this module. - ModuleVersion = '0.0.2' + ModuleVersion = '0.0.3' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/tests/Alias-Helper.Tests.ps1 b/tests/Alias-Helper.Tests.ps1 index 3d89e74..11e0c21 100644 --- a/tests/Alias-Helper.Tests.ps1 +++ b/tests/Alias-Helper.Tests.ps1 @@ -11,6 +11,8 @@ Describe 'Alias-Helper' { $script:JSON_FILE_PATH = "$PSScriptRoot\aliases-test.json" $script:JSON_CONTENT = Get-Content -Path $script:JSON_FILE_PATH | ConvertFrom-Json + $env:LOCALAPPDATA = "localappdata" + Mock New-Item Mock Test-Path { return $true } } From b9c86e4111f7c85fe0444a63c49a04518be241c5 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Wed, 22 Oct 2025 21:59:37 +0200 Subject: [PATCH 4/4] adds extra test case --- tests/Alias-Helper.Tests.ps1 | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/Alias-Helper.Tests.ps1 b/tests/Alias-Helper.Tests.ps1 index 11e0c21..e00ac56 100644 --- a/tests/Alias-Helper.Tests.ps1 +++ b/tests/Alias-Helper.Tests.ps1 @@ -63,10 +63,26 @@ Describe 'Alias-Helper' { } } context 'Get-Script-Path' { - It 'Returns correct path' { - + It 'Creates directory and file if not exist' { + Mock Test-Path { return $false } + Mock New-Item + Get-Script-Path - | Should -Be "$env:LOCALAPPDATA\quickpath\aliases.json" + + Assert-MockCalled -CommandName New-Item -Times 2 -Exactly -Scope It + Assert-MockCalled -CommandName New-Item -Times 1 -Exactly -Scope It -ParameterFilter { + $Path -eq (Join-Path $env:LOCALAPPDATA 'quickpath') -and $ItemType -eq 'Directory' + } + Assert-MockCalled -CommandName New-Item -Times 1 -Exactly -Scope It -ParameterFilter { + $Path -eq (Join-Path (Join-Path $env:LOCALAPPDATA 'quickpath') 'aliases.json') -and $ItemType -eq 'File' + } + } + It 'Returns correct file path' { + $expectedPath = Join-Path (Join-Path $env:LOCALAPPDATA 'quickpath') 'aliases.json' + + $result = Get-Script-Path + + $result | Should -Be $expectedPath } } context 'Get-Alias' {