Skip to content

Commit

Permalink
Workaround for breaking upstream change
Browse files Browse the repository at this point in the history
Closes ef4#20
  • Loading branch information
ef4 committed Feb 9, 2015
1 parent 9dfcf77 commit 625a310
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/caching-browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,24 @@ module.exports = CoreObject.extend({
b.add('./' + self.inFile);

b.on('package', function(pkg){
self._watchModules[pkg.__dirname] = true;
// browserify *used to* reliably put the package's directory in
// pkg.__dirname. But as of browser-resolve 1.7.0 that isn't
// true, and we sometimes get a value here like
// '/path/to/your-module/index' instead of
// '/path/to/your-module'. So we do our own checking.
var pkgDir = pkg.__dirname;
var stat;
try {
stat = fs.statSync(pkgDir);
} catch(err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
if (!stat || !stat.isDirectory()) {
pkgDir = path.dirname(pkgDir);
}
self._watchModules[pkgDir] = true;
});

b.on('dep', function (dep) {
Expand Down

0 comments on commit 625a310

Please sign in to comment.