Skip to content

Commit daa4182

Browse files
committedOct 31, 2021
chore: Run prettier
1 parent c110ed1 commit daa4182

File tree

6 files changed

+281
-286
lines changed

6 files changed

+281
-286
lines changed
 

‎README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ A [Readable Stream][readable-stream-url] interface over [node-glob][node-glob-ur
1515
```js
1616
var gs = require('glob-stream');
1717

18-
var readable = gs('./files/**/*.coffee', { /* options */ });
18+
var readable = gs('./files/**/*.coffee', {
19+
/* options */
20+
});
1921

20-
var writable = /* your WriteableStream */
22+
var writable =
23+
/* your WriteableStream */
2124

22-
readable.pipe(writable);
25+
readable.pipe(writable);
2326
```
2427

25-
You can pass any combination of glob strings. One caveat is that you cannot __only__ pass a negative glob, you must give it at least one positive glob so it knows where to start. If given a non-glob path (also referred to as a singular glob), only one file will be emitted. If given a singular glob and no files match, an error is emitted (see also [`options.allowEmpty`][allow-empty-url]).
28+
You can pass any combination of glob strings. One caveat is that you cannot **only** pass a negative glob, you must give it at least one positive glob so it knows where to start. If given a non-glob path (also referred to as a singular glob), only one file will be emitted. If given a singular glob and no files match, an error is emitted (see also [`options.allowEmpty`][allow-empty-url]).
2629

2730
## API
2831

@@ -68,7 +71,7 @@ Default: `process.cwd()`
6871

6972
The root path that the glob is resolved against.
7073

71-
__Note: This is never passed to [node-glob][node-glob-url] because it is pre-resolved against your paths.__
74+
**Note: This is never passed to [node-glob][node-glob-url] because it is pre-resolved against your paths.**
7275

7376
Type: `String`
7477

@@ -110,14 +113,16 @@ var stream = gs(['./**/*.js', '!./node_modules/**/*']);
110113

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

113-
The following would __not__ exclude any files:
116+
The following would **not** exclude any files:
117+
114118
```js
115-
gs(['!b*.js', '*.js'])
119+
gs(['!b*.js', '*.js']);
116120
```
117121

118122
However, this would exclude all files that started with `b`:
123+
119124
```js
120-
gs(['*.js', '!b*.js'])
125+
gs(['*.js', '!b*.js']);
121126
```
122127

123128
## glob-stream for enterprise
@@ -126,7 +131,6 @@ Available as part of the Tidelift Subscription
126131

127132
The maintainers of glob-stream and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-glob-stream?utm_source=npm-glob-stream&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
128133

129-
130134
## License
131135

132136
MIT

‎index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ function globStream(globs, opt) {
2020
ourOpt.dot = typeof ourOpt.dot === 'boolean' ? ourOpt.dot : false;
2121
ourOpt.silent = typeof ourOpt.silent === 'boolean' ? ourOpt.silent : true;
2222
ourOpt.cwdbase = typeof ourOpt.cwdbase === 'boolean' ? ourOpt.cwdbase : false;
23-
ourOpt.uniqueBy = typeof ourOpt.uniqueBy === 'string' ||
24-
typeof ourOpt.uniqueBy === 'function' ? ourOpt.uniqueBy : 'path';
23+
ourOpt.uniqueBy =
24+
typeof ourOpt.uniqueBy === 'string' || typeof ourOpt.uniqueBy === 'function'
25+
? ourOpt.uniqueBy
26+
: 'path';
2527

2628
if (ourOpt.cwdbase) {
2729
ourOpt.base = ourOpt.cwd;
@@ -82,7 +84,7 @@ function globStream(globs, opt) {
8284
}
8385

8486
function indexGreaterThan(index) {
85-
return function(obj) {
87+
return function (obj) {
8688
return obj.index > index;
8789
};
8890
}

‎readable.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function GlobStream(ourGlob, negatives, opt) {
6767

6868
var found = false;
6969

70-
globber.on('match', function(filepath) {
70+
globber.on('match', function (filepath) {
7171
found = true;
7272
var obj = {
7373
cwd: cwd,
@@ -79,7 +79,7 @@ function GlobStream(ourGlob, negatives, opt) {
7979
}
8080
});
8181

82-
globber.once('end', function() {
82+
globber.once('end', function () {
8383
if (allowEmpty !== true && !found && globIsSingular(globber)) {
8484
var err = new Error(globErrMessage1 + ourGlob + globErrMessage2);
8585

@@ -97,16 +97,16 @@ function GlobStream(ourGlob, negatives, opt) {
9797
}
9898
inherits(GlobStream, Readable);
9999

100-
GlobStream.prototype._read = function() {
100+
GlobStream.prototype._read = function () {
101101
this._globber.resume();
102102
};
103103

104-
GlobStream.prototype.destroy = function(err) {
104+
GlobStream.prototype.destroy = function (err) {
105105
var self = this;
106106

107107
this._globber.abort();
108108

109-
process.nextTick(function() {
109+
process.nextTick(function () {
110110
if (err) {
111111
self.emit('error', err);
112112
}

‎test/fixtures/whatsgoingon/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
what
1+
what;

‎test/index.js

+234-228
Large diffs are not rendered by default.

‎test/readable.js

+23-40
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,17 @@ var through = miss.through;
1919

2020
var dir = deWindows(__dirname);
2121

22-
describe('readable stream', function() {
23-
24-
it('emits an error if there are no matches', function(done) {
22+
describe('readable stream', function () {
23+
it('emits an error if there are no matches', function (done) {
2524
function assert(err) {
2625
expect(err.message).toMatch(/^File not found with singular glob/g);
2726
done();
2827
}
2928

30-
pipe([
31-
stream('notfound', [], { cwd: dir }),
32-
concat(),
33-
], assert);
29+
pipe([stream('notfound', [], { cwd: dir }), concat()], assert);
3430
});
3531

36-
it('throws an error if you try to write to it', function(done) {
32+
it('throws an error if you try to write to it', function (done) {
3733
var gs = stream('notfound', [], { cwd: dir });
3834
gs.on('error', function () {});
3935

@@ -45,7 +41,7 @@ describe('readable stream', function() {
4541
}
4642
});
4743

48-
it('does not throw an error if you push to it', function(done) {
44+
it('does not throw an error if you push to it', function (done) {
4945
var stub = {
5046
cwd: dir,
5147
base: dir,
@@ -61,13 +57,10 @@ describe('readable stream', function() {
6157
expect(pathObjs[0]).toEqual(stub);
6258
}
6359

64-
pipe([
65-
gs,
66-
concat(assert),
67-
], done);
60+
pipe([gs, concat(assert)], done);
6861
});
6962

70-
it('accepts a file path', function(done) {
63+
it('accepts a file path', function (done) {
7164
var expected = {
7265
cwd: dir,
7366
base: dir + '/fixtures',
@@ -79,13 +72,13 @@ describe('readable stream', function() {
7972
expect(pathObjs[0]).toMatchObject(expected);
8073
}
8174

82-
pipe([
83-
stream('./fixtures/test.coffee', [], { cwd: dir }),
84-
concat(assert),
85-
], done);
75+
pipe(
76+
[stream('./fixtures/test.coffee', [], { cwd: dir }), concat(assert)],
77+
done
78+
);
8679
});
8780

88-
it('accepts a glob', function(done) {
81+
it('accepts a glob', function (done) {
8982
var expected = [
9083
{
9184
cwd: dir,
@@ -111,19 +104,19 @@ describe('readable stream', function() {
111104
expect(pathObjs).toContainEqual(expected[2]);
112105
}
113106

114-
pipe([
115-
stream('./fixtures/**/*.dmc', [], { cwd: dir }),
116-
concat(assert),
117-
], done);
107+
pipe(
108+
[stream('./fixtures/**/*.dmc', [], { cwd: dir }), concat(assert)],
109+
done
110+
);
118111
});
119112

120-
it('pauses the globber upon backpressure', function(done) {
113+
it('pauses the globber upon backpressure', function (done) {
121114
var gs = stream('./fixtures/**/*.dmc', [], { cwd: dir, highWaterMark: 1 });
122115

123116
var spy = sinon.spy(gs._globber, 'pause');
124117

125118
function waiter(pathObj, _, cb) {
126-
setTimeout(function() {
119+
setTimeout(function () {
127120
cb(null, pathObj);
128121
}, 500);
129122
}
@@ -134,14 +127,10 @@ describe('readable stream', function() {
134127
sinon.restore();
135128
}
136129

137-
pipe([
138-
gs,
139-
through.obj({ highWaterMark: 1 }, waiter),
140-
concat(assert),
141-
], done);
130+
pipe([gs, through.obj({ highWaterMark: 1 }, waiter), concat(assert)], done);
142131
});
143132

144-
it('destroys the stream with an error if no match is found', function(done) {
133+
it('destroys the stream with an error if no match is found', function (done) {
145134
var gs = stream('notfound', []);
146135

147136
var spy = sinon.spy(gs, 'destroy');
@@ -153,13 +142,10 @@ describe('readable stream', function() {
153142
done();
154143
}
155144

156-
pipe([
157-
gs,
158-
concat(),
159-
], assert);
145+
pipe([gs, concat()], assert);
160146
});
161147

162-
it('destroys the stream if node-glob errors', function(done) {
148+
it('destroys the stream if node-glob errors', function (done) {
163149
var expectedError = new Error('Stubbed error');
164150

165151
var gs = stream('./fixtures/**/*.dmc', [], { cwd: dir, silent: true });
@@ -178,9 +164,6 @@ describe('readable stream', function() {
178164
done();
179165
}
180166

181-
pipe([
182-
gs,
183-
concat(),
184-
], assert);
167+
pipe([gs, concat()], assert);
185168
});
186169
});

0 commit comments

Comments
 (0)
Please sign in to comment.