Crumbtrail
    Preparing search index...

    Interface IZFileSystemService

    Represents a service to enumerate the file system.

    interface IZFileSystemService {
        info(path: string): Promise<IZFileSystemNode>;
        search(
            pattern: string | string[],
            options?: IZFileSystemSearchOptions,
        ): Promise<IZFileSystemNode[]>;
        walk(
            search: string,
            options?: IZFileSystemWalkOptions,
        ): Promise<string | null>;
    }

    Implemented by

    Index

    Methods

    Methods

    • Walks up a directory tree to search for existence of a given path.

      Parameters

      • search: string

        The path to search for. This is the candidate folder path that may or may not exist somewhere from the start directory all the way up the directory tree.

      • Optionaloptions: IZFileSystemWalkOptions

        The given options for the search.

      Returns Promise<string | null>

      The fully qualified path to the first path that matches the search starting at the options start or the current working directory if not specified. Returns null if no such directory exists.

      import { resolve } from 'path'

      // Find any folder named .vscode from the current working directory all the way
      // up the directory tree. Returns null if no vscode directory can be found.
      const service = new ZFileSystemService();
      const vscode = service.walk('.vscode');

      // Walk the directory tree from the current script and find the .config folder.
      const config = service.walk('.config', { start: __dirname });

      // Walk the directory tree from the current script and stop when we reach
      // at most 2 directories up.
      const start = __dirname;
      const stop = resolve(__dirname, '../..');
      const file = service.walk('path/to/file.json', { start, stop });