jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

Calling useref.assets() breaks fs.stat #138

Closed lexi-lambda closed 8 years ago

lexi-lambda commented 9 years ago

I've managed to track down the source of a fairly subtle bug to this dependency. The bug does not appear to be in gulp-useref itself, but in the vinyl-fs dependency. However, vinyl-fs has fixed this bug in version 2.0.0, so it is gulp-useref that now needs to be updated to use the new version. (In fact, the bug is in a dependency of vinyl-fs as well, which has been updated in the new version, but that is irrelevant.)

The bug rarely comes up, but when it does, it's hard to figure out what's causing it. It's easy to demonstrate, though:

useref.assets();
console.log(fs.stat(filePath) instanceof fs.Stats); // false

The result of fs.stat will not be an instance of fs.Stats, which is a guarantee that should be maintained. As far as I can tell, this bug originates in https://github.com/isaacs/node-graceful-fs/issues/31, but it percolates up through the dependencies.

Unfortunately, I tried updating vinyl-fs myself, but that causes the tests to fail, so it'll take some tweaking beyond just updating the dependency.

jonkemp commented 9 years ago

I'll take a look. Thanks.

jonkemp commented 9 years ago

Not sure why upgrading vinyl-fs breaks the tests.

jonkemp commented 8 years ago

The codebase here has been updated with the latest version of vinyl-fs. Can you clone this repo and link it to your project to see if it works? If not, it should be available on npm soon.

jonkemp commented 8 years ago

Fixed in 2.0.0.

79c2a0e