Skip to content

feat: support try option for all utils#258

Open
8ctavio wants to merge 7 commits intounjs:mainfrom
8ctavio:fix/try-support
Open

feat: support try option for all utils#258
8ctavio wants to merge 7 commits intounjs:mainfrom
8ctavio:fix/try-support

Conversation

@8ctavio
Copy link
Copy Markdown

@8ctavio 8ctavio commented Jan 23, 2026

Resolves #257

  • Add MaybeTry utility type to resolve return type of functions that accept try.
  • Add try support for findFile (required so that functions using findFile may also suppress errors), findNearestFile, and findFarthestFile.
  • Add try support for findPackage, readPackage, and updatePackage.
  • Add readPackage test for returning undefined instead of throwing error with try: true.

@8ctavio 8ctavio changed the title Fix/try support fix(package.json): implement readPackage's try option support Jan 23, 2026
@pi0 pi0 changed the title fix(package.json): implement readPackage's try option support feat(readPackage): support try option support Feb 16, 2026
@pi0 pi0 changed the title feat(readPackage): support try option support feat(readPackage): support try option Feb 16, 2026
@pi0 pi0 changed the title feat(readPackage): support try option feat: support try option for all utils Feb 16, 2026
Comment thread src/resolve/types.ts
*
* @default false
*/
try?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm feeling maybe we should call it tryResolve, as calls can throw error if reading (permissions) or parsing (malformed) errors happen.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For the functions in resolve/utils.ts there is no problem in renaming to tryResolve. But should the findPackage, readPackage, and updatePackage functions keep their try option (extended from exsolve's ResolveOptions)? When calling utils from those functions, options could be transformed like this: { ...options, tryResolve: options.try }. Other alternative would be to Omit try and replace with tryResolve.

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.

readPackage's try option is unimplemented

2 participants