@guanghechen/locate-helper
    TypeScript icon, indicating that this package has built-in type declarations

    1.8.3 • Public • Published

    @guanghechen/locate-helper


    Utils for locate nearest filepath matched the given pattern.

    Install

    • npm

      npm install --save @guanghechen/locate-helper
    • yarn

      yarn add @guanghechen/locate-helper

    Usage

    locateNearestFilepath

    export function locateNearestFilepath(
      currentDir: string,
      filenames: string[],
    ): string | null

    Locate 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 | null

    Find 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 | null

    Find the latest package.json under the give currentDir or its ancestor path.

    • currentDir: The starting directory of the locating.

    Install

    npm i @guanghechen/locate-helper

    DownloadsWeekly Downloads

    13

    Version

    1.8.3

    License

    MIT

    Unpacked Size

    7.28 kB

    Total Files

    5

    Last publish

    Collaborators

    • lemonclown