badmotorfinger / z

Save time typing out directory paths in PowerShell by jumping around instead.
The Unlicense
425 stars 32 forks source link

Exception on first import #33

Closed wekempf closed 6 years ago

wekempf commented 6 years ago

The first time you import the module on a new system you receive the following.

PS> import-module z
Get-Content : Cannot find path 'C:\Users\bkempf\.cdHistory' because it does not exist.
At C:\Users\bkempf\Documents\WindowsPowerShell\Modules\z\1.1.7\z.psm1:624 char:20
+ ... global:history += Get-Content -Path $cdHistory -Encoding UTF8 | ? { ( ...
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\bkempf\.cdHistory:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

I don't have time to look at the code or provide a PR, but simply wrapping this functionality with a Test-Path check would fix it.

badmotorfinger commented 6 years ago

Thanks for taking the time to log this issue.

Issue resolved. You can grab the latest version for the PowerShell gallery.