gulpjs / vinyl

Virtual file format.
MIT License
1.28k stars 105 forks source link

Correct File.clone() treatment of File.stats #8

Closed hughsk closed 10 years ago

hughsk commented 10 years ago

Cloning the stats object would remove its prototype, meaning it would lose methods normally available on fs.Stats instances, such as Stats.isDirectory() or Stats.isFile()

This was giving me errors when cloning vinyl instances and then piping them to gulp.dest() streams, which do a directory check if the stats property is present:

/Users/hughsk/Desktop/repos/gulp/lib/createOutputStream/index.js:19
      if (file.stat && file.stat.isDirectory()) {
                                 ^
TypeError: Object #<Object> has no method 'isDirectory'
    at /Users/hughsk/Desktop/repos/gulp/lib/createOutputStream/index.js:19:34
    at /Users/hughsk/Desktop/repos/gulp/node_modules/mkdirp/index.js:38:26
    at Object.oncomplete (fs.js:107:15)

This should fix the problem :)

hughsk commented 10 years ago

@Contra using the freshly published clone-stats module now, look good to merge?

yocontra commented 10 years ago

@hughsk the module needs tests and so does this PR

hughsk commented 10 years ago

@Contra done, for both.