recursive-readdir-files
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.2 • Public • Published

    recursive-readdir-files

    Coverage Status npm version

    Node.js module to list all files in a directory or any subdirectories.

    Installation

    npm install recursive-readdir-files

    Usage

    const recursiveReaddirFiles = require("recursive-readdir-files");
    
    recursiveReaddirFiles(process.cwd(), {
      ignored: /\/(node_modules|\.git)/
    })
    .then((files) => {
      // `files` is an array
      console.log(files);
    })
    .catch((error) => {
      console.error("something exploded", error);
    });

    Options

    export interface RecursiveReaddirFilesOptions {
      /**
       * Ignore files
       * @example `/\/(node_modules|\.git)/`
       */
      ignored?: RegExp;
      /**
       * Specifies a list of `glob` patterns that match files to be included in compilation. 
       * @example `/(\.json)$/`
       */
      include?: RegExp;
      /**
       * Specifies a list of files to be excluded from compilation.
       * @example `/(package\.json)$/`
       */
      exclude?: RegExp;
    }

    Result

    export interface IFileDirStat {
      /**
       * E.g: `/a/sum.jpg` => `sum.jpg`;
       */
      name: string;
      /**
       * E.g: `/basic/src/utils/sum.ts`
       */
      path: string;
      /**
       * E.g: `/a/b.jpg` => `jpg`;
       */
      ext?: string;
      size?: number;
    }
    
    export default function recursiveReaddirFiles(rootPath: string, options?: RecursiveReaddirFilesOptions): Promise<IFileDirStat[]>;
    
    /**
     * Get ext
     * @param {String} filePath `/a/b.jpg` => `jpg`
     */
    export declare const getExt: (filePath: string) => string;

    License

    Licensed under the MIT License.

    Install

    npm i recursive-readdir-files

    DownloadsWeekly Downloads

    341

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    10.7 kB

    Total Files

    7

    Last publish

    Collaborators

    • wcjiang