Skip to content

Commit 09db435

Browse files
generalov-aidemurgos
authored andcommitted
Replace event-stream dependency by readable-stream
1 parent b096453 commit 09db435

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var es = require('event-stream');
3+
var stream = require('readable-stream');
44
var log = require('fancy-log');
55
var tinyLr = require('tiny-lr');
66
var relative = require('path').relative;
@@ -39,10 +39,12 @@ var options = {
3939
module.exports = exports = function(opts) {
4040
options = _assign(options, opts);
4141

42-
var glr = es.map(function(file, done) {
42+
var glr = new stream.PassThrough({
43+
objectMode: true,
44+
});
45+
glr.on('data', function(file) {
4346
var filePath = file.path;
4447
exports.changed(filePath);
45-
done(null, file);
4648
});
4749

4850
if (options.start) exports.listen(options);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"dependencies": {
2222
"chalk": "^2.4.1",
2323
"debug": "^3.1.0",
24-
"event-stream": "3.3.4",
2524
"fancy-log": "^1.3.2",
2625
"lodash.assign": "^4.2.0",
26+
"readable-stream": "^3.0.6",
2727
"tiny-lr": "^1.1.1",
2828
"vinyl": "^2.2.0"
2929
},

test/index.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var assert = require('assert');
4-
var es = require('event-stream');
4+
var stream = require('readable-stream');
55
var path = require('path');
66
var sinon = require('sinon');
77
var tinyLr = require('tiny-lr');
@@ -14,6 +14,14 @@ var file = new Vinyl({ base: cwd, cwd: cwd, path: cwd + '/style.css' });
1414
var keys = ['basePath', 'key', 'cert', 'start', 'quiet', 'reloadPage'];
1515
var srv, log;
1616

17+
function readable(callback) {
18+
var r = new stream.Readable({
19+
objectMode: true
20+
});
21+
callback.apply(r)
22+
return r;
23+
}
24+
1725
describe('gulp-livereload', function() {
1826
beforeEach(function() {
1927
srv = sinon.stub(tinyLr, 'Server');
@@ -30,10 +38,9 @@ describe('gulp-livereload', function() {
3038
it('does not work', function(done) {
3139
var spy = sinon.spy();
3240
srv.returns({ changed: spy , listen: function() {}});
33-
es.readable(function(count, next) {
34-
this.emit('data', file);
35-
this.emit('end');
36-
next();
41+
readable(function() {
42+
this.push(file);
43+
this.push(null);
3744
})
3845
.pipe(glr({ basePath: cwd }))
3946
.on('end', function() {
@@ -46,10 +53,9 @@ describe('gulp-livereload', function() {
4653
srv.returns({ changed: spy , listen: function() {}});
4754
var lr = glr();
4855
glr.listen();
49-
es.readable(function(count, next) {
50-
this.emit('data', file);
51-
this.emit('end');
52-
next();
56+
readable(function() {
57+
this.push(file);
58+
this.push(null);
5359
})
5460
.pipe(lr)
5561
.on('end', function() {
@@ -115,10 +121,9 @@ describe('gulp-livereload', function() {
115121
var spy = sinon.spy();
116122
srv.returns({ changed: spy , listen: function() {}});
117123
glr.listen();
118-
es.readable(function(count, next) {
119-
this.emit('data', file);
120-
this.emit('end');
121-
next();
124+
readable(function() {
125+
this.push(file);
126+
this.push(null);
122127
})
123128
.pipe(glr({ basePath: process.cwd() }))
124129
.on('end', function() {
@@ -129,10 +134,9 @@ describe('gulp-livereload', function() {
129134
it('option: start', function(done) {
130135
var spy = sinon.spy();
131136
srv.returns({ changed: spy , listen: function() {}});
132-
es.readable(function(count, next) {
133-
this.emit('data', file);
134-
this.emit('end');
135-
next();
137+
readable(function() {
138+
this.push(file);
139+
this.push(null);
136140
})
137141
.pipe(glr({ start: true }))
138142
.on('end', function() {

0 commit comments

Comments
 (0)