How to use glob-stream - 10 common examples

To help you get started, we’ve selected a few glob-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdittmer / web-apis / lib / idl / LocalSourceRunner.es6.js View on Github external
run() {
    // TODO: Do something more robust?
    if (this.running) throw new Error('LocalSourceRunner already running');
    this.running = true;

    // Clear runner-output-data.
    this.eachFilePromises = [];
    this.fileResults = [];

    this.sourceHash = this.getGitHash();

    // Compose fresh set of memos for main pipeline computation(s).
    this.pipeline = this.createPipeline();

    // Find files for pipeline inputs
    this.globStream = gs.create(`${this.sourcePath}/**/*.${this.extension}`, {
      ignore: this.ignoreGlobs,
    });
    this.globStream.on(
      'data',
      file => this.processFile(file.path.substr(`${this.sourcePath}/`.length))
    );

    // Return Promise handled by streaming input event listeners.
    return new Promise((resolve, reject) => {
      this.globStream.on('error', error => {
        return Promise.resolve(this.onError(resolve, reject, error));
      });
      this.globStream.on('end', data => {
        return Promise.all(this.eachFilePromises).then(
          this.onDataReady.bind(this, resolve, reject, data),
          this.onError.bind(this, resolve, reject)
github BorisMoore / jsrender / gulpfile.js View on Github external
gulp.task('bundle', function() {
	var tmplify = require('./tmplify');
	var gs = require('glob-stream');

	return gs.create('./test/browserify/*-unit-tests.js')
		.on('data', function(file) {
			// file has path, base, and cwd attrs
			var fileName = file.path.slice(file.base.length, -14);
			browserify(file.path, {debug:true})
				.transform(tmplify)
				.bundle()
				.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
				.on('error', function(err) {
					// Make sure failed tests cause gulp to exit non-zero 
					throw err;
				});
		});
});
github agershun / alasql / node_modules / gulp / node_modules / vinyl-fs / lib / src / index.js View on Github external
if (!isValidGlob(glob)) {
    throw new Error('Invalid glob argument: ' + glob);
  }
  // return dead stream if empty array
  if (Array.isArray(glob) && glob.length === 0) {
    process.nextTick(pass.end.bind(pass));
    return pass;
  }

  var options = defaults({}, opt, {
    read: true,
    buffer: true
  });

  var globStream = gs.create(glob, options);

  // when people write to use just pass it through
  var outputStream = globStream
    .pipe(through.obj(createFile))
    .pipe(getStats(options));

  if (options.read !== false) {
    outputStream = outputStream
      .pipe(getContents(options));
  }

  return outputStream.pipe(pass);
}
github FredHutch / Oncoscape / client / node_modules / gulp-useref / node_modules / vinyl-fs / lib / src / index.js View on Github external
}, opt);
  var pass, inputPass;

  if (!isValidGlob(glob)) {
    throw new Error('Invalid glob argument: ' + glob);
  }
  // return dead stream if empty array
  if (Array.isArray(glob) && glob.length === 0) {
    pass = through.obj();
    if (!options.passthrough) {
      process.nextTick(pass.end.bind(pass));
    }
    return pass;
  }

  var globStream = gs.create(glob, options);

  var outputStream = globStream
    .pipe(resolveSymlinks())
    .pipe(through.obj(createFile));

  if (options.since) {
    outputStream = outputStream
      .pipe(filterSince(options.since));
  }

  if (options.read !== false) {
    outputStream = outputStream
      .pipe(getContents(options));
  }

  if (options.passthrough) {
github BorisMoore / jsviews / gulpfile.js View on Github external
gulp.task('bundle', function() {
	var tmplify = require('jsrender/tmplify');
	var gs = require('glob-stream');

	return gs.create('./test/browserify/*-unit-tests.js')
		.on('data', function(file) {
			// file has path, base, and cwd attrs
			var fileName = file.path.slice(file.base.length, -14);
			browserify(file.path, {debug:true})
				.transform(tmplify)
				.bundle()
				.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
				.on('error', function(err) {
					// Make sure failed tests cause gulp to exit non-zero 
					throw err;
				});
		});
});
github BorisMoore / jsviews.com / gulpfile.js View on Github external
gulp.task('bundle', function() {
	var tmplify = require('jsrender/tmplify');
	var gs = require('glob-stream');

	return gs.create('./test/browserify/*-unit-tests.js')
		.on('data', function(file) {
			// file has path, base, and cwd attrs
			var fileName = file.path.slice(file.base.length, -14);
			browserify(file.path, {debug:true})
				.transform(tmplify)
				.bundle()
				.pipe(fs.createWriteStream('./test/browserify/bundles/' + fileName + "-bundle.js"))
				.on('error', function(err) {
					// Make sure failed tests cause gulp to exit non-zero 
					throw err;
				});
		});
});
github microsoft / vscode-js-debug / src / common / sourceMaps / nodeSourceMapRepository.ts View on Github external
await new Promise((resolve, reject) =>
      globStream(
        [
          ...patterns.map(forceForwardSlashes),
          // Avoid reading asar files: electron patches in support for them, but
          // if we see an invalid one then it throws a synchronous error that
          // breaks glob. We don't care about asar's here, so just skip that:
          '!**/*.asar/**',
        ],
        {
          matchBase: true,
          cwd: base,
        },
      )
        .on('data', (value: globStream.Entry) =>
          todo.push(
            createMetadataForFile(fixDriveLetterAndSlashes(value.path))
              .then(parsed => parsed && onChild(parsed))
github mdittmer / web-apis / lib / idl / BlinkLinkedRunner.es6.js View on Github external
run() {
    // TODO: Do something more robust?
    if (this.running) throw new Error('BlinkLinkedRunner already running');
    this.running = true;

    // Clear runner-output-data.
    this.filesProcessed = [];
    this.urlsToFiles = {};
    this.urlsToParses = {};

    // Compose fresh set of memos for main pipeline computation(s).
    this.pipeline = this.createPipeline();

    // Find files for pipeline inputs
    this.globStream = gs.createStream(`${this.blinkPath}/**/*.idl`, [], {});
    this.globStream.on(
      'data',
      file => this.processFile(file.path.substr(`${this.blinkPath}/`.length))
    );

    // Return Promise handled by streaming input event listeners.
    return new Promise((resolve, reject) => {
      this.globStream.on('error', error => {
        return Promise.resolve(this.onError(resolve, reject, error));
      });
      this.globStream.on('end', data => {
        return Promise.all(this.eachFilePromises).then(
          this.onDataReady.bind(this, resolve, reject, data),
          this.onError.bind(this, resolve, reject)
        );
      });
github isiahmeadows / thallium / lib / cli / old / cli.js View on Github external
function (result, next) {
                    var callback = self.makeNext(next)

                    gs.createStream(result.files, {allowEmpty: true})
                    .on("error", callback)
                    .on("data", function (data) {
                        // This will never be equal if `this.data.config` is
                        // `null`.
                        /* eslint-disable global-require */

                        if (data !== self.data.config) require(data)

                        /* eslint-enable global-require */
                    })
                    .on("end", callback)
                },
github peter-mouland / web-caddy / tasks / utils / fs.js View on Github external
function glob(globArray){
    var stream = gs.create(globArray, { allowEmpty: true });
    return new Promise(function(resolve, reject){
        var files = [];
        stream.on('data', function(fileObj){
            files.push(new File(fileObj));
        });
        stream.on('end', function(err){
            err && reject(err);
            !err && resolve(files);
        });

    });
}

glob-stream

Readable streamx interface over anymatch.

MIT
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis