fs-jetpack icon indicating copy to clipboard operation
fs-jetpack copied to clipboard

find matching recursively upward

Open jasonkuhrt opened this issue 5 years ago • 5 comments

It would be nice to have a way to find files in or upward of cwd. This is common for e.g. finding the nearest tsconfig.json, package.json, ... etc.

For performance and intent-representation reasons I think it would make sense to have an option to short-circuit at first match. The TS types could use this flag to change the return type (via conditional typing), e.g.:

With find 1 semantic on:

null | string

With off:

string[]

jasonkuhrt avatar Nov 12 '19 21:11 jasonkuhrt

This is a great idea, I would do a PR on this if I had the time... I am currently super busy though.

papb avatar Nov 13 '19 12:11 papb

Glad you like it @papb! We've been benefiting from this library on some work at Prisma Labs. Its good to at least know you're buying into the idea. Maybe our team (myself or @weakky) will find an opportunity on our side to contribute a PR toward this issue.

jasonkuhrt avatar Nov 13 '19 13:11 jasonkuhrt

Fantastic :)

papb avatar Nov 13 '19 16:11 papb

Sounds interesting, I'm also super busy till the end of this year, after that can investigate this feature as well. But don't hesitate to be faster than me :)

szwacz avatar Nov 15 '19 10:11 szwacz

Closely related: sindresorhus/find-up

papb avatar Nov 25 '19 20:11 papb