badmotorfinger / z

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

Fix "Cannot find path..." error on first run #21

Closed daniel-liuzzi closed 8 years ago

daniel-liuzzi commented 8 years ago
Remove-Item : Cannot find path 'C:\Users\Daniel\.cdHistory' because it does not exist.
At C:\Program Files (x86)\WindowsPowerShell\Modules\z\1.1.3\z.psm1:458 char:3
+   Remove-Item $cdHistory
+   ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Daniel\.cdHistory:String) [Remove-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

The above error appears when first changing directory after the module is installed (i.e. when .cdHistory doest not yet exist.) Although a .cdHistory file is created and subsequent directory changes work fine, the error does seem a bit scary, especially for first time users. Also, WriteHistoryToDisk() is slightly simplified by removing the temporary file, as it seems unnecessary.

badmotorfinger commented 8 years ago

Thank you for your time :+1: