Skip to content

fix: preserve truthy defaults when glob options are passed as undefined - #199

Merged
SuperchupuDev merged 6 commits into
SuperchupuDev:mainfrom
chloeelim:main
Apr 11, 2026
Merged

fix: preserve truthy defaults when glob options are passed as undefined#199
SuperchupuDev merged 6 commits into
SuperchupuDev:mainfrom
chloeelim:main

Conversation

@chloeelim

@chloeelim chloeelim commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a regression introduced in #170 where spreading user-supplied glob options over defaultOptions allowed explicit undefined values to overwrite the truthy defaults.

The old normalizeCwd function guarded against the undefined cwd explicitly, but the refactor lost that guard.

This PR introduces a fix to getOptions which now iterates over the fixed set of defaultOptions keys, filling in any user-supplied option that is undefined.

Closes #198


Tests

Added tests verifying that the glob options all apply their truthy defaults when passed explicitly as undefined.

fixes spreading over glob option inputs containing explicit `undefined`
values to use the truthy defaults
@pkg-pr-new

pkg-pr-new Bot commented Apr 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/tinyglobby@199

commit: dcd9da9

process.cwd() was captured once in defaultOptions at import time,
causing process.chdir() calls and test mocks to have no effect.

@SuperchupuDev SuperchupuDev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot for fixing this regression ❤️ i have two small nits but other than that it looks good to me!!

Comment thread src/index.ts Outdated
Comment thread test/index.test.ts Outdated
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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! mocked it instead in fix(test): mock process.cwd() method in cwd test! wonder if that's better?

chloeelim and others added 2 commits April 9, 2026 19:58
Co-authored-by: Madeline Gurriarán <53496941+SuperchupuDev@users.noreply.github.com>
Comment thread test/index.test.ts Outdated

@SuperchupuDev SuperchupuDev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for reporting the bug and for submitting a fix so quickly, this would've taken a lot longer without your help ❤️

@SuperchupuDev
SuperchupuDev merged commit a37f27a into SuperchupuDev:main Apr 11, 2026
8 checks passed
SuperchupuDev added a commit that referenced this pull request Apr 11, 2026
we don't need to manually restore mocks, as pointed out in #199
@kevinmarrec

Copy link
Copy Markdown

@SuperchupuDev Any idea when 0.2.17 is landing ? :)

@SuperchupuDev

Copy link
Copy Markdown
Owner

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

@kevinmarrec

kevinmarrec commented Apr 22, 2026

Copy link
Copy Markdown

No real rush for me, I just made my Renovate/Dependabot settings to stop bumping tinyglobby (even pinned) for now, I can wait :)

@SuperchupuDev

Copy link
Copy Markdown
Owner

hi! just fyi 0.2.17 is out now with the fix :^) @kevinmarrec

@kevinmarrec

Copy link
Copy Markdown

Great 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

truthy defaults ignored when glob options are explicitly passed as undefined

3 participants