Socket
Socket
Sign inDemoInstall

glob-stream

Package Overview
Dependencies
62
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    glob-stream

A wrapper around node-glob to make it streamy


Version published
Maintainers
3
Install size
854 kB
Created

Package description

What is glob-stream?

The glob-stream npm package allows for reading file paths from a globbing pattern. It is a wrapper around node-glob and vinyl-fs to stream the file objects that match the glob patterns. This package is particularly useful in build processes and file manipulation scripts where matching files based on patterns is required.

What are glob-stream's main functionalities?

Reading files using glob patterns

This feature allows you to read files that match a specific pattern. In the code sample, all JavaScript files under the 'src' directory and its subdirectories are matched and their paths are logged.

const globStream = require('glob-stream');

const stream = globStream('./src/**/*.js');
stream.on('data', function(file) {
  console.log(file.path);
});

Combining multiple glob patterns

glob-stream supports combining multiple patterns, including exclusion patterns. In this example, all JavaScript files under 'src' except those in the 'vendor' subdirectory are matched.

const globStream = require('glob-stream');

const stream = globStream(['./src/**/*.js', '!./src/vendor/**']);
stream.on('data', function(file) {
  console.log(file.path);
});

Other packages similar to glob-stream

Readme

Source

glob-stream

NPM version Downloads Build Status Coveralls Status Gitter chat

A wrapper around node-glob to make it streamy.

Usage

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

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

stream.on('data', function(file){
  // file has path, base, and cwd attrs
});

You can pass any combination of globs. One caveat is that you can not only pass a glob negation, you must give it at least one positive glob so it knows where to start. All given must match for the file to be returned.

API

create(globs, options)

Returns a stream for multiple globs or filters.

createStream(positiveGlob, negativeGlobs, options)

Returns a stream for a single glob or filter.

Options

  • cwd
    • Default is process.cwd()
  • base
    • Default is everything before a glob starts (see glob-parent)
  • cwdbase
    • Default is false
    • When true it is the same as saying opt.base = opt.cwd
  • allowEmpty
    • Default is false
    • If true, won't emit an error when a glob pointing at a single file fails to match
  • Any through2 related options are documented in through2

This argument is passed directly to node-glob so check there for more options

Glob

var stream = gs.create(['./**/*.js', '!./node_modules/**/*']);

Globs are executed in order, so negations should follow positive globs. For example:

gulp.src(['!b*.js', '*.js'])

would not exclude any files, but this would

gulp.src(['*.js', '!b*.js'])
  • globby - Non-streaming glob wrapper with support for multiple patterns.

License

MIT

Keywords

FAQs

Last updated on 26 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc