File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ function gulpRename(obj) {
16
16
} ;
17
17
}
18
18
19
- stream . _transform = function ( file , unused , callback ) {
19
+ stream . _transform = function ( originalFile , unused , callback ) {
20
20
21
+
22
+ var file = originalFile . clone ( { contents : false } ) ;
21
23
var parsedPath = parsePath ( file . relative ) ;
22
24
var path ;
23
25
Original file line number Diff line number Diff line change 2
2
/* global helper, helperError */
3
3
4
4
require ( './spec-helper' ) ;
5
+ var rename = require ( '../' ) ;
6
+ var gulp = require ( 'gulp' ) ;
7
+ var Path = require ( 'path' ) ;
5
8
6
9
describe ( 'gulp-rename' , function ( ) {
7
10
context ( 'with string parameter' , function ( ) {
@@ -172,6 +175,50 @@ describe('gulp-rename', function () {
172
175
} ) ;
173
176
} ) ;
174
177
178
+ context ( 'in parallel streams' , function ( ) {
179
+ it ( 'only changes the file in the current stream' , function ( done ) {
180
+ var files = gulp . src ( 'test/fixtures/hello.txt' ) ;
181
+
182
+ var pipe1 = files . pipe ( rename ( { suffix : '-1' } ) ) ;
183
+ var pipe2 = files . pipe ( rename ( { suffix : '-2' } ) ) ;
184
+ var end1 = false ;
185
+ var end2 = false ;
186
+ var file1 ;
187
+ var file2 ;
188
+
189
+ pipe1
190
+ . on ( 'data' , function ( file ) {
191
+ file1 = file ;
192
+ } )
193
+ . on ( 'end' , function ( ) {
194
+ end1 = true ;
195
+
196
+ if ( end2 ) {
197
+ return check ( ) ;
198
+ }
199
+ } ) ;
200
+
201
+ pipe2
202
+ . on ( 'data' , function ( file ) {
203
+ file2 = file ;
204
+ } )
205
+ . on ( 'end' , function ( ) {
206
+ end2 = true ;
207
+
208
+ if ( end1 ) {
209
+ return check ( ) ;
210
+ }
211
+ } ) ;
212
+
213
+ function check ( ) {
214
+ file1 . path . should . equal ( Path . resolve ( 'test/fixtures/hello-1.txt' ) ) ;
215
+ file2 . path . should . equal ( Path . resolve ( 'test/fixtures/hello-2.txt' ) ) ;
216
+
217
+ return done ( ) ;
218
+ }
219
+ } ) ;
220
+ } ) ;
221
+
175
222
context ( 'throws unsupported parameter type' , function ( ) {
176
223
var srcPattern ;
177
224
beforeEach ( function ( ) {
You can’t perform that action at this time.
0 commit comments