glob-fs-dotfiles

raw JSON →
0.1.6 verified Sat Apr 25 auth: no javascript deprecated

A middleware package for glob-fs that automatically ignores dotfiles (files and directories starting with a dot) during file globbing. Version 0.1.6 is the latest and only release. It was originally a built-in middleware for glob-fs but can be used directly when the default middleware stack is disabled. Key differentiators: provides fine-grained control over dotfile handling via options like 'dot', 'dotdirs', 'dotfiles'. The package is part of the glob-fs ecosystem but is deprecated in favor of glob-fs's built-in support.

error TypeError: glob.use is not a function
cause glob-fs not imported correctly or not installed; glob.use is undefined.
fix
Install glob-fs: npm install glob-fs --save and require it before using .use().
error Error: Must be used with glob-fs
cause This middleware is not used in the context of glob-fs.
fix
Create a glob-fs instance first: var glob = require('glob-fs')(options); glob.use(require('glob-fs-dotfiles')());
error Error: Expected a function, but got something else in middleware
cause Forgot to call dotfiles() as a function; passed the exported value directly.
fix
Change .use(require('glob-fs-dotfiles')) to .use(require('glob-fs-dotfiles')())
deprecated Package is deprecated; functionality is built into glob-fs as default middleware.
fix Use glob-fs without this package; dotfiles are ignored by default. Or if you need to include them, use options.dot: true in glob-fs.
gotcha Must be used with glob-fs; standalone usage not possible.
fix Ensure glob-fs is installed and you create a glob-fs instance before using this middleware.
gotcha Requires calling dotfiles() as a function to get the middleware, not the exported value itself.
fix Use .use(dotfiles()) instead of .use(dotfiles).
breaking If you want to include dotfiles, you must pass options to the middleware: dotfiles({dot: true}).
fix Use dotfiles({dot: true}) to include dotfiles; otherwise they are ignored.
npm install glob-fs-dotfiles
yarn add glob-fs-dotfiles
pnpm add glob-fs-dotfiles

Shows require and use of glob-fs-dotfiles middleware with glob-fs, including disabling built-ins for explicit control.

var dotfiles = require('glob-fs-dotfiles');
var glob = require('glob-fs')({ builtins: false }) // disable built-ins
  .use(dotfiles()) // apply dotfiles middleware
  .readdir('*', function(err, files) {
    if (err) console.error(err);
    else console.log(files);
  });