Skip to content

feat(explorer): add a searchUpTo option for bounded upward search - #6

Merged
Mearman merged 2 commits into
mainfrom
feat/search-up-to
Oct 1, 2026
Merged

Mearman merged 2 commits into
mainfrom
feat/search-up-to

Conversation

@Mearman

@Mearman Mearman commented Oct 1, 2026

Copy link
Copy Markdown
Member

Adds a searchUpTo option to createExplorer: a directory searches the start directory and each parent up to and including it, and 'project' stops at the first directory with a package file. Passing it together with cosmiconfig.searchStrategy or cosmiconfig.stopDir throws and names both.

The issue left open what global with stopDir does about the OS config directory. I checked the installed cosmiconfig 9.0.2 and 10.0.1 source and probed both with HOME pointed at a scratch directory: it always yields the OS config directory last, whatever stopDir is, and also when the start is outside stopDir. There is no option to turn that off, so a directory bound can't map to global and still keep the user's global config out. It is instead a walk over the parents with the none strategy, which checks one directory per call; project never leaves the project, so it maps straight across. The README documents this, and the interop tests pin the cosmiconfig behaviour in both majors so a change upstream shows up as a failure.

The bound is lexical and does not follow symlinks.

Closes #3

A directory searches the start directory and each parent up to and
including it, by calling a none-strategy explorer once per directory.
cosmiconfig's global strategy cannot express this: it always ends by
checking the OS config directory, whatever stopDir is. 'project' maps to
the project strategy. Combining searchUpTo with cosmiconfig.searchStrategy
or cosmiconfig.stopDir throws, naming both options.
…To relies on

Runs against cosmiconfig 9 and 10: none checks one directory, project
stops at a package file, stopDir is inclusive and only valid with global,
and global still checks the OS config directory after stopDir.
@Mearman
Mearman marked this pull request as ready for review October 1, 2026 07:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-01T07:34:49.593110Z e8a6559 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit e2e32f9 into main Oct 1, 2026
12 checks passed
@Mearman
Mearman deleted the feat/search-up-to branch October 1, 2026 07:35
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createExplorer: a searchUpTo option for bounded upward search

1 participant