Skip to content

Commit

Permalink
feat!: Switch to streamx (#119)
Browse files Browse the repository at this point in the history
chore: Ensure project works with different streams
chore: Add tests showing globbing of many files
chore: Longer timeout for windows tests
chore: Update docs to mention streamx
fix: Resolve cwd to support relative cwd paths
fix: Normalize cwd on windows
  • Loading branch information
phated authored Apr 23, 2023
1 parent 5097aed commit 8d6b35c
Show file tree
Hide file tree
Showing 4 changed files with 929 additions and 835 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

A [Readable Stream][readable-stream-url] interface over [anymatch][anymatch-url].
[Readable streamx][streamx-url] interface over [anymatch][anymatch-url].

## Usage

Expand Down Expand Up @@ -104,7 +104,7 @@ MIT
[picomatch-options-url]: https://github.com/micromatch/picomatch#options
[glob-parent-url]: https://github.com/es128/glob-parent
[allow-empty-url]: #optionsallowempty
[readable-stream-url]: https://nodejs.org/api/stream.html#stream_readable_streams
[streamx-url]: https://github.com/streamxorg/streamx#readable-stream

[downloads-image]: https://img.shields.io/npm/dm/glob-stream.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/glob-stream
Expand Down
20 changes: 7 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var EventEmitter = require('events');

var fastq = require('fastq');
var anymatch = require('anymatch');
var Readable = require('readable-stream').Readable;
var Readable = require('streamx').Readable;
var isGlob = require('is-glob');
var globParent = require('glob-parent');
var normalizePath = require('normalize-path');
Expand Down Expand Up @@ -172,7 +172,6 @@ function globStream(globs, opt) {
var ourOpt = Object.assign(
{},
{
highWaterMark: 16,
cwd: process.cwd(),
dot: false,
cwdbase: false,
Expand All @@ -188,6 +187,8 @@ function globStream(globs, opt) {

validateOptions(ourOpt);

ourOpt.cwd = normalizePath(path.resolve(ourOpt.cwd), true);

var base = ourOpt.base;
if (ourOpt.cwdbase) {
base = ourOpt.cwd;
Expand All @@ -196,10 +197,9 @@ function globStream(globs, opt) {
var walker = walkdir();

var stream = new Readable({
objectMode: true,
highWaterMark: ourOpt.highWaterMark,
read: read,
destroy: destroy,
predestroy: predestroy,
});

// Remove path relativity to make globs make sense
Expand All @@ -217,19 +217,13 @@ function globStream(globs, opt) {
walker.once('error', onError);
walker.walk(ourOpt.cwd);

function read() {
function read(cb) {
walker.resume();
cb();
}

function destroy(err) {
function predestroy() {
walker.end();

process.nextTick(function () {
if (err) {
stream.emit('error', err);
}
stream.emit('close');
});
}

function resolveGlob(glob) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glob-stream",
"version": "7.0.0",
"description": "A Readable Stream interface over anymatch.",
"description": "Readable streamx interface over anymatch.",
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
"contributors": [
"Eric Schoffstall <yo@contra.io>",
Expand Down Expand Up @@ -30,16 +30,16 @@
"is-glob": "^4.0.3",
"is-negated-glob": "^1.0.0",
"normalize-path": "^3.0.0",
"readable-stream": "^3.6.0"
"streamx": "^2.12.5"
},
"devDependencies": {
"eslint": "^7.0.0",
"eslint-config-gulp": "^5.0.0",
"eslint-plugin-node": "^11.1.0",
"expect": "^27.0.0",
"mississippi": "^4.0.0",
"mocha": "^8.0.0",
"nyc": "^15.0.1",
"readable-stream": "^3.6.0",
"sinon": "^9.2.3"
},
"nyc": {
Expand Down
Loading

0 comments on commit 8d6b35c

Please sign in to comment.