Skip to content

Commit 3f76e4b

Browse files
committed
changed file creation which was shallow cloning anyways to use clone always with deep:false, and contents: false
1 parent 4bb8d2d commit 3f76e4b

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ gulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })
309309

310310
- `clone`
311311

312-
Clones the original file for creation of the map file. Could be important if file history is important. See [file.clone()](https://github.com/gulpjs/vinyl#filecloneoptions) for possible options. Default: `undefined`
312+
Clones the original file for creation of the map file. Could be important if file history is important. See [file.clone()](https://github.com/gulpjs/vinyl#filecloneoptions) for possible options. Default: `{deep:false, contents:false}`
313313

314314
### Plugin developers only:
315315

src/write.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,7 @@ function write(destPath, options) {
149149
}
150150

151151
var sourceMapFile;
152-
if (options.clone !== undefined) {
153-
// add new source map file to stream, clone from original to keep file.history
154-
sourceMapFile = file.clone(options.clone);
155-
} else {
156-
// add new source map file to stream
157-
sourceMapFile = new File({
158-
cwd: file.cwd,
159-
base: file.base
160-
});
161-
}
152+
sourceMapFile = file.clone(options.clone || {deep:false, contents:false});
162153
sourceMapFile.path = sourceMapPath;
163154
sourceMapFile.contents = new Buffer(JSON.stringify(sourceMap));
164155
sourceMapFile.stat = {

test/write.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ test('write: should write external map files', function(t) {
188188
}).write(file);
189189
});
190190

191-
test('write: should keep original file history', function(t) {
191+
test('write:clone - should keep original file history', function(t) {
192192
var file = makeFile();
193-
var pipeline = sourcemaps.write('../maps', {destPath: 'dist', clone: true});
193+
var pipeline = sourcemaps.write('../maps', {destPath: 'dist'});
194194
var outFiles = [];
195195
var fileCount = 0;
196196
pipeline

0 commit comments

Comments
 (0)