wbyoung / avn

Automatic Version Switching for Node
MIT License
1.14k stars 54 forks source link

Test RegEx not catching all cases #63

Closed duckontheweb closed 6 years ago

duckontheweb commented 6 years ago

Please describe your issue clearly and also include all details below.

Details

The output of __avn_debug in the directory with a .node-version file is:

# paste output here

avn is loaded in my ~/.{bash|zsh}{_profile|rc} file with:

# find the relevant line(s) in your profile & note path above

nvm specific

I am starting in on a PR for #43, but I have a couple of tests failing. One of them is the fails for any failed action test in test/setup.js, which give the following failed test output:

AssertionError: expected 'error: EACCES: permission denied, open \'/var/folders/1p/9z6dp_4n2cd27d2ktj6w_xv40000gn/T/d-1171011-15092-10e8ilz.4tsh8h0k9/.bash_profile\'\n' to match /^error: EACCES.*, open '[\/\w-]*\/.bash_profile'\n$/

It looks like the regex is just not catching my error message case. I can dig into the regex and fix it to catch this, but I wanted to bring this to your attention in case it's a known issue that I should ignore.

duckontheweb commented 6 years ago

This is the old regex:

/^error: EACCES.*, open '[\/\w-]*\/.bash_profile'\n$/

This is the updated regex that catches my case:

/^error: EACCES.*, open '[\/\w-\d\.]*\/.bash_profile'\n$/

The changes were matching digits and the dot character in the directory portion before .bash_profile. I've tested this locally and the test now passes.

wbyoung commented 6 years ago

@duckontheweb looks like a good change. Please feel free to throw up a separate PR.