traverse: {
    forFile: ((dir, file) => Promise<Optional<string>>);
    forFileSync: ((dir, file) => Optional<string>);
} = ...

These methods were moved from the deprecated 'fs' module in v2 and are only used in sfdx-core above

They were migrated into the 'traverse' constant in order to stub them in unit tests

Type declaration

  • forFile: ((dir, file) => Promise<Optional<string>>)

    Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a specific file name. Resolves with the directory path containing the located file, or null if the file was not found.

      • (dir, file): Promise<Optional<string>>
      • Parameters

        • dir: string

          The directory path in which to start the upward search.

        • file: string

          The file name to look for.

        Returns Promise<Optional<string>>

  • forFileSync: ((dir, file) => Optional<string>)

    Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a specific file name. Resolves with the directory path containing the located file, or null if the file was not found.

      • (dir, file): Optional<string>
      • Parameters

        • dir: string

          The directory path in which to start the upward search.

        • file: string

          The file name to look for.

        Returns Optional<string>