Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

glob-stream

gulpjs10.5mMIT8.0.2TypeScript support: definitely-typed

Readable streamx interface over anymatch.

glob, stream, gulp, readable, fs, files

readme

glob-stream

NPM version Downloads Build Status Coveralls Status

Readable streamx interface over anymatch.

Usage

var gs = require('glob-stream');

var readable = gs('./files/**/*.coffee', {
  /* options */
});

var writable =
  /* your WriteableStream */

  readable.pipe(writable);

You can pass any combination of glob strings. One caveat is that you cannot only pass a negative glob, you must give it at least one positive glob so it knows where to start. If given a non-glob path (also referred to as a singular glob), only one file will be emitted. If given a singular glob and no files match, an error is emitted (see also options.allowEmpty).

API

globStream(globs, [options])

Takes a glob string or an array of glob strings as the first argument and an options object as the second. Returns a stream of objects that contain cwd, base and path properties.

Options

options.allowEmpty

Whether or not to error upon an empty singular glob.

Type: Boolean

Default: false (error upon no match)

options.dot

Whether or not to treat dotfiles as regular files. This is passed through to anymatch.

Type: Boolean

Default: false

options.cwd

The current working directory that the glob is resolved against.

Type: String

Default: process.cwd()

options.root

The root path that the glob is resolved against.

Type: String

Default: undefined (use the filesystem root)

options.base

The absolute segment of the glob path that isn't a glob. This value is attached to each glob object and is useful for relative pathing.

Type: String

Default: The absolute path segement before a glob starts (see glob-parent)

options.cwdbase

Whether or not the cwd and base should be the same.

Type: Boolean

Default: false

options.uniqueBy

Filters stream to remove duplicates based on the string property name or the result of function. When using a function, the function receives the streamed data (objects containing cwd, base, path properties) to compare against.

Type: String or Function

Default: 'path'

other

Any glob-related options are documented in picomatch.

License

MIT

changelog

Changelog

8.0.2 (2024-04-08)

Bug Fixes

  • Avoid blowing the call stack when processing many files (#133) (bb21c9d)
  • Avoid following circular symlinks (#126) (cf8b197)
  • Only traverse directories that can match the glob base (#131) (8e74e21)

8.0.1 (2024-03-25)

Bug Fixes

  • Avoid pushing additional paths to queue when error occurs (#124) (8eaab85)
  • Traverse symlink folders (#122) (d49d9bd)

8.0.0 (2023-04-23)

⚠ BREAKING CHANGES

  • Switch to streamx (#119)
  • Combine GlobStream & GlobReadable into unified API
  • Replace glob with anymatch & custom directory walk (#118)
  • Drop support for ordered globs (#115)

Features

  • Combine GlobStream & GlobReadable into unified API (6aad264)
  • Replace glob with anymatch & custom directory walk (#118) (6aad264)
  • Switch to streamx (#119) (8d6b35c)

Bug Fixes

  • Normalize cwd on windows (8d6b35c)
  • Properly handle glob-like characters in paths (#117) (872a957)
  • Resolve cwd to support relative cwd paths (8d6b35c)

Miscellaneous Chores

7.0.0 (2021-10-31)

⚠ BREAKING CHANGES

  • Normalize repository, dropping node <10.13 support (#101)

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (#101) (c110ed1)