Options
All
  • Public
  • Public/Protected
  • All
Menu

@pkemp/dirtraverse

Index

Interfaces

Functions

Functions

traverse

  • traverse(filepath: string, callback: (err: Error, filepath: string, stats: fs.Stats) => boolean): Promise<void>
  • Traverse directory and call a callback with each file/folder. If callback return true for a folder, it's content will be skipped.

    Example

    const dirtraverse = require('@pkemp/dirtraverse');
    
    dirtraverse.traverse('.', (err, filepath, stats) => {
     console.log('Callback called with path: ', filepath);
      return stats.isDirectory() && path.basename(filepath) === '.git'    // return true if you want to skip traversal of a subfolder
    });
    

    Parameters

    • filepath: string

      Path to the folder for starting point.

    • callback: (err: Error, filepath: string, stats: fs.Stats) => boolean

      The callback is called with each folder and file. In case of error the err is not null.

        • (err: Error, filepath: string, stats: fs.Stats): boolean
        • Parameters

          • err: Error
          • filepath: string
          • stats: fs.Stats

          Returns boolean

    Returns Promise<void>

    Promise

Generated using TypeDoc