@guanghechen/locate-helper v1.9.8
Utils for locate nearest filepath matched the given pattern.
Install
npm
npm install --save @guanghechen/locate-helperyarn
yarn add @guanghechen/locate-helper
Usage
locateNearestFilepath
export function locateNearestFilepath(
currentDir: string,
filenames: string[],
): string | nullLocate a nearest filepath from the given currentDir which name included
in the give filenames.
currentDir: The starting directory of the locating.filenames: The file name list of the file to be searched, the first existed filepath in the list will be returned as the result.
findNearestFilepath
export function findNearestFilepath(
currentDir: string,
testFilepath: (filepath: string) => boolean,
): string | nullFind a nearest filepath from the give currentDirwhich matched the give
tester testFilepath.
currentDir: The starting directory of the searching.testFilepath: Test if a given filepath is an expected one.
locateLatestPackageJson
export function locateLatestPackageJson(currentDir: string): string | nullFind the latest package.json under the give currentDir or its ancestor path.
currentDir: The starting directory of the locating.
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago