2.2.3 • Published 2 years ago

recursive-readdir v2.2.3

Weekly downloads
5,137,776
License
MIT
Repository
github
Last release
2 years ago

recursive-readdir

Build Status

Recursively list all files in a directory and its subdirectories. It does not list the directories themselves.

Because it uses fs.readdir, which calls readdir under the hood on OS X and Linux, the order of files inside directories is not guaranteed.

Installation

npm install recursive-readdir

Usage

var recursive = require("recursive-readdir");

recursive("some/path", function (err, files) {
  // `files` is an array of file paths
  console.log(files);
});

It can also take a list of files to ignore.

var recursive = require("recursive-readdir");

// ignore files named "foo.cs" or files that end in ".html".
recursive("some/path", ["foo.cs", "*.html"], function (err, files) {
  console.log(files);
});

You can also pass functions which are called to determine whether or not to ignore a file:

var recursive = require("recursive-readdir");

function ignoreFunc(file, stats) {
  // `file` is the path to the file, and `stats` is an `fs.Stats`
  // object returned from `fs.lstat()`.
  return stats.isDirectory() && path.basename(file) == "test";
}

// Ignore files named "foo.cs" and descendants of directories named test
recursive("some/path", ["foo.cs", ignoreFunc], function (err, files) {
  console.log(files);
});

Promises

You can omit the callback and return a promise instead.

var recursive = require("recursive-readdir");

recursive("some/path").then(
  function(files) {
    console.log("files are", files);
  },
  function(error) {
    console.error("something exploded", error);
  }
);

The ignore strings support Glob syntax via minimatch.

react-dev-utils@bsolution/bsolution-dev-utils@proteria/react-scripts@uukit/react-dev-kit@react-ssr/corehapi-timefsrouterfsrouter-expressgorbyasset-cloudbp-skeletonepi2me-apinodehal@rock-kit/ui-icons-build@datev_eg/vuepress-offlinesearch-parse-cligulp-pug-template-underscorevuln-func-validator@moquality/codelabsass-styleguide-with-puguno-h5bionicmetricsmqlabwits-for-testwits-for-test-1wits-for-test-3wits-for-test-betawits-test1wits-test14wits-test2wits-test20wits-test3wits-test5wits-test55wits-test7task-service-container@spotify-backstage/cli@tizentv/witstestgatsby-blog-cliwits-beta-testfundocyaiact-cli@tizentv/test@cashremit/cr-streamline-iconswooooosikwooooosik11wooooosik12wooooosik13wooooosik5wooooosik7wooooosik8@tizentv/testmodulealacustomer@omake/react-scriptscustom-react-scripts-with-modules@mohitsingh/react-scriptsorion-builder-cli@shipengine/cli@shipengine/integration-platform-clicudo@mygooder/react-dev-utilsaochef@tkil/tmpl-clicustom-react-dev-utils-anjan@simon-id/temp-testreact-dev-utils-anjan@app-server/clidist-deploymentcerebro-search-projectsp-react-dev-utilsyarik-testxardazantdeco-react-dev-utils@modngn/server@nbarinov/commonnode_contrast@slaty/synctranslation-parserstudiosyncsaffyre@texttree/demo-bsa-reference-rcl@klizan/react-dev-utilsgradverwebflow-react@temporg/ui-icons-build@askphill/sync@wulihua/dist-deploy@m_shine_ray/fecli8basefelfirefelfire-aws-s3alr-react-dev-utilsanodizenode-ssh-deploygenerator-expensy@rari-capital/solidity-coveragesolanum-studiosparrow-bird-server@cloud-carbon-footprint/create-app-dev-dev@kununu/react-universal-scripts@you54f/s3-batch-upload
2.2.3

2 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.3.0

9 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.2

11 years ago

0.0.1

13 years ago