Skip to content

Commit

Permalink
handle symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisirhc committed Jun 30, 2015
1 parent f9c2561 commit ceaef13
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var readonly = require('read-only-stream');
module.exports = Browserify;
inherits(Browserify, EventEmitter);

var fs = require('fs');
var path = require('path');
var paths = {
empty: path.join(__dirname, 'lib/_empty.js')
Expand Down Expand Up @@ -481,7 +482,7 @@ Browserify.prototype._createDeps = function (opts) {
return cb(null, paths.empty, {});
}
}
cb(err, file, pkg);
cb(err, fs.realpathSync(file), pkg);
});
};

Expand Down
16 changes: 16 additions & 0 deletions test/symlink_dedupe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var browserify = require('../');
var vm = require('vm');
var test = require('tap').test;

test('hash instances with hashed contexts', function (t) {
t.plan(5);

var b = browserify(__dirname + '/symlink_dedupe/main.js');
b.bundle(function (err, buf) {
var c = { t: t };
var src = buf.toString('utf8');
t.equal(src.match(RegExp('// FILE F ONE', 'g')).length, 1);
t.equal(src.match(RegExp('// FILE G ONE', 'g')).length, 1);
vm.runInNewContext(src, c);
});
});
6 changes: 6 additions & 0 deletions test/symlink_dedupe/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var A = require('./one/f.js');
var B = require('./one/dir/f.js');
t.equal(A, B);
t.equal(A(), 555);
t.equal(B(), 555);

1 change: 1 addition & 0 deletions test/symlink_dedupe/one/dir
3 changes: 3 additions & 0 deletions test/symlink_dedupe/one/f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// FILE F ONE
var G = require('./g.js');
module.exports = function () { return 111 * G };
2 changes: 2 additions & 0 deletions test/symlink_dedupe/one/g.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// FILE G ONE
module.exports = 5

0 comments on commit ceaef13

Please sign in to comment.