Skip to content

Commit 8d6b35c

Browse files
authoredApr 23, 2023
feat!: Switch to streamx (#119)
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
1 parent 5097aed commit 8d6b35c

File tree

4 files changed

+929
-835
lines changed

4 files changed

+929
-835
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

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

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

1313
## Usage
1414

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

109109
[downloads-image]: https://img.shields.io/npm/dm/glob-stream.svg?style=flat-square
110110
[npm-url]: https://www.npmjs.com/package/glob-stream

‎index.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var EventEmitter = require('events');
66

77
var fastq = require('fastq');
88
var anymatch = require('anymatch');
9-
var Readable = require('readable-stream').Readable;
9+
var Readable = require('streamx').Readable;
1010
var isGlob = require('is-glob');
1111
var globParent = require('glob-parent');
1212
var normalizePath = require('normalize-path');
@@ -172,7 +172,6 @@ function globStream(globs, opt) {
172172
var ourOpt = Object.assign(
173173
{},
174174
{
175-
highWaterMark: 16,
176175
cwd: process.cwd(),
177176
dot: false,
178177
cwdbase: false,
@@ -188,6 +187,8 @@ function globStream(globs, opt) {
188187

189188
validateOptions(ourOpt);
190189

190+
ourOpt.cwd = normalizePath(path.resolve(ourOpt.cwd), true);
191+
191192
var base = ourOpt.base;
192193
if (ourOpt.cwdbase) {
193194
base = ourOpt.cwd;
@@ -196,10 +197,9 @@ function globStream(globs, opt) {
196197
var walker = walkdir();
197198

198199
var stream = new Readable({
199-
objectMode: true,
200200
highWaterMark: ourOpt.highWaterMark,
201201
read: read,
202-
destroy: destroy,
202+
predestroy: predestroy,
203203
});
204204

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

220-
function read() {
220+
function read(cb) {
221221
walker.resume();
222+
cb();
222223
}
223224

224-
function destroy(err) {
225+
function predestroy() {
225226
walker.end();
226-
227-
process.nextTick(function () {
228-
if (err) {
229-
stream.emit('error', err);
230-
}
231-
stream.emit('close');
232-
});
233227
}
234228

235229
function resolveGlob(glob) {

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "glob-stream",
33
"version": "7.0.0",
4-
"description": "A Readable Stream interface over anymatch.",
4+
"description": "Readable streamx interface over anymatch.",
55
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
66
"contributors": [
77
"Eric Schoffstall <yo@contra.io>",
@@ -30,16 +30,16 @@
3030
"is-glob": "^4.0.3",
3131
"is-negated-glob": "^1.0.0",
3232
"normalize-path": "^3.0.0",
33-
"readable-stream": "^3.6.0"
33+
"streamx": "^2.12.5"
3434
},
3535
"devDependencies": {
3636
"eslint": "^7.0.0",
3737
"eslint-config-gulp": "^5.0.0",
3838
"eslint-plugin-node": "^11.1.0",
3939
"expect": "^27.0.0",
40-
"mississippi": "^4.0.0",
4140
"mocha": "^8.0.0",
4241
"nyc": "^15.0.1",
42+
"readable-stream": "^3.6.0",
4343
"sinon": "^9.2.3"
4444
},
4545
"nyc": {

‎test/index.js

+917-817
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.