11'use strict' ;
22
33var assert = require ( 'assert' ) ;
4- var es = require ( 'event -stream' ) ;
4+ var stream = require ( 'readable -stream' ) ;
55var path = require ( 'path' ) ;
66var sinon = require ( 'sinon' ) ;
77var tinyLr = require ( 'tiny-lr' ) ;
@@ -14,6 +14,14 @@ var file = new Vinyl({ base: cwd, cwd: cwd, path: cwd + '/style.css' });
1414var keys = [ 'basePath' , 'key' , 'cert' , 'start' , 'quiet' , 'reloadPage' ] ;
1515var 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+
1725describe ( '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