Skip to content

fix(tools-node): limit package dependency search scope#4154

Open
vivekjm wants to merge 1 commit into
microsoft:mainfrom
vivekjm:fix-801-package-search-stop-dir
Open

fix(tools-node): limit package dependency search scope#4154
vivekjm wants to merge 1 commit into
microsoft:mainfrom
vivekjm:fix-801-package-search-stop-dir

Conversation

@vivekjm
Copy link
Copy Markdown

@vivekjm vivekjm commented May 16, 2026

Description

Resolves #801.

This adds a stopDir option to findPackageDependencyDir so callers can keep dependency lookup bounded to a repository root instead of walking all the way up the filesystem. The stop directory itself remains part of the search, so root-level node_modules is still found.

A regression test covers both cases: a dependency above stopDir is ignored, while a dependency at stopDir/node_modules is still resolved.

Test plan

  • PATH="$HOME/.nvm/versions/node/v22.22.0/bin:$PATH" yarn workspace @rnx-kit/tools-node test
  • PATH="$HOME/.nvm/versions/node/v22.22.0/bin:$PATH" yarn workspace @rnx-kit/tools-node build
  • PATH="$HOME/.nvm/versions/node/v22.22.0/bin:$PATH" yarn workspace @rnx-kit/tools-node lint
  • PATH="$HOME/.nvm/versions/node/v22.22.0/bin:$PATH" yarn change:check

Note: the default local Node v20.15.0 cannot run the repo test command because it lacks fs.globSync; the commands above were run with local Node v22.22.0.

Comment thread packages/tools-node/src/package.ts Outdated
@vivekjm vivekjm force-pushed the fix-801-package-search-stop-dir branch from db43dbf to 98283fc Compare May 22, 2026 12:19
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.

Limit the scope of file and directory searching when resolving modules

2 participants