🔎 🎯 flipfind
find and resolve files automatically searches nearby paths in an optimized order
usage
yarn add flipfindnpm i flipfind --save
// can be used as a class for chaining and debuggingconst Finder = // or as a function for easier funconst finder =
🔊 debug
const found = Finderall
👣 steps
to optimize, it will go through the steps in order and return
once it finds the correct existing path. If .debug is used with .all
, it will go through every step and output the results so you can see the process.
- if a file and dir are given, it will attempt to resolve using file + dir
- if the given file is absolute, and if it exists
- checks with the cwd
- checks with require.main extracts the dirname from it
- checks the app-root-path
- checks a glob for very near files
- filters to ensure it does-include the file and/or dir passed in through options
- checks with the mono-root
📘 examples
// will return nullconst found = Finder // without extFinder// with extFinder// can use relative, Finder// or shorthandFinder// with dirFinderdir'test/fixtures' // return an objectconst abs file name ext dir = Finder // as function
📝 todo
- add fallback for resolving a file that does not yet exist - currently is
null
, will require an option - cache the results