find-dominant-file
Return the filename or parent directory path of a file or directory by walking
up parent directories. The package name is from emacs builtin lisp function
find-dominant-file
. This package supports TypeScript as well.
Installation
npm i find-dominant-file -s
Usage
/foo
└── bar
└── baz
├── qux
└── quxx
└── quxxx
├── quxxxx
└── quxxxxx
const myFile = ;//=> '/foo/bar/baz/quxx'const myDir = ;//=> '/foo/bar/baz'
API
findDominantFile(dir, filename)
Returns the path of file or undefined.
findDominantFile(dir, filename, true)
Returns the path of the directory which contains the file or undefined.
findDominantFile(dir, [filename, ...])
Returns the path of the first found file in the list or undefined.
findDominantFile(dir, [filename, ...], true)
Returns the path of the directory which contains the first found file in the list or undefined.
License
MIT © Zhang Kai Yu