Skip to content

feat!: Switch to streamx #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]> (https://gulpjs.com/)",
"contributors": [
"Eric Schoffstall <[email protected]>",
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