fix: preserve truthy defaults when glob options are passed as undefined - #199
Conversation
fixes spreading over glob option inputs containing explicit `undefined` values to use the truthy defaults
commit: |
process.cwd() was captured once in defaultOptions at import time, causing process.chdir() calls and test mocks to have no effect.
SuperchupuDev
left a comment
There was a problem hiding this comment.
thanks a lot for fixing this regression ❤️ i have two small nits but other than that it looks good to me!!
| test('cwd defaults to process.cwd() evaluated at call time, not import time', async () => { | ||
| const importTimeCwd = process.cwd(); | ||
| try { | ||
| process.chdir(cwd); // cwd !== importTimeCwd (fixture is in a temp dir) |
There was a problem hiding this comment.
i am slightly afraid that changing the current directory might mess with tests, but it looks like tests are passing, so it's probably not a big deal
There was a problem hiding this comment.
good point! mocked it instead in fix(test): mock process.cwd() method in cwd test! wonder if that's better?
Co-authored-by: Madeline Gurriarán <53496941+SuperchupuDev@users.noreply.github.com>
SuperchupuDev
left a comment
There was a problem hiding this comment.
thank you for reporting the bug and for submitting a fix so quickly, this would've taken a lot longer without your help ❤️
we don't need to manually restore mocks, as pointed out in #199
|
@SuperchupuDev Any idea when 0.2.17 is landing ? :) |
|
i was gonna wait some days to see if i can close more issues before releasing but i can hurry up if anyone needs the release :^) i can try doing the release this week |
|
No real rush for me, I just made my Renovate/Dependabot settings to stop bumping |
|
hi! just fyi 0.2.17 is out now with the fix :^) @kevinmarrec |
|
Great 🎉 |
Description
Fixes a regression introduced in #170 where spreading user-supplied glob options over
defaultOptionsallowed explicitundefinedvalues to overwrite the truthy defaults.The old
normalizeCwdfunction guarded against the undefinedcwdexplicitly, but the refactor lost that guard.This PR introduces a fix to
getOptionswhich now iterates over the fixed set ofdefaultOptionskeys, filling in any user-supplied option that isundefined.Closes #198
Tests
Added tests verifying that the glob options all apply their truthy defaults when passed explicitly as undefined.