Skip to content

Commit

Permalink
[breaking] make preserveSymlinks false by default
Browse files Browse the repository at this point in the history
followup to browserify#131
  • Loading branch information
zkochan authored and ljharb committed Sep 1, 2017
1 parent bdf1210 commit 75108bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/node-modules-paths.js
Expand Up @@ -11,7 +11,7 @@ module.exports = function nodeModulesPaths(start, opts) {
// resolving against the process' current working directory
var absoluteStart = path.resolve(start);

if (opts && opts.preserveSymlinks === false) {
if (!opts || !opts.preserveSymlinks) {
try {
absoluteStart = fs.realpathSync(absoluteStart);
} catch (err) {
Expand Down
8 changes: 2 additions & 6 deletions readme.markdown
Expand Up @@ -73,8 +73,6 @@ options are:

* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
**Note:** this property is currently `true` by default but it will be changed to
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.

default `opts` values:

Expand All @@ -94,7 +92,7 @@ default `opts` values:
});
},
moduleDirectory: 'node_modules',
preserveSymlinks: true
preserveSymlinks: false
}
```

Expand Down Expand Up @@ -127,8 +125,6 @@ options are:

* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
**Note:** this property is currently `true` by default but it will be changed to
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.

default `opts` values:

Expand All @@ -148,7 +144,7 @@ default `opts` values:
return stat.isFile() || stat.isFIFO();
},
moduleDirectory: 'node_modules',
preserveSymlinks: true
preserveSymlinks: false
}
````

Expand Down
6 changes: 3 additions & 3 deletions test/symlinks.js
Expand Up @@ -17,7 +17,7 @@ try {
test('symlink', function (t) {
t.plan(1);

resolve('foo', { basedir: symlinkDir, preserveSymlinks: false }, function (err, res, pkg) {
resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) {
if (err) t.fail(err);
t.equal(res, path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js'));
});
Expand All @@ -26,7 +26,7 @@ test('symlink', function (t) {
test('sync symlink when preserveSymlinks = true', function (t) {
t.plan(4);

resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) {
resolve('foo', { basedir: symlinkDir, preserveSymlinks: true }, function (err, res, pkg) {
t.ok(err, 'there is an error');
t.notOk(res, 'no result');

Expand All @@ -48,7 +48,7 @@ test('sync symlink', function (t) {

test('sync symlink when preserveSymlinks = true', function (t) {
t.throws(function () {
resolve.sync('foo', { basedir: symlinkDir });
resolve.sync('foo', { basedir: symlinkDir, preserveSymlinks: true });
}, /Cannot find module 'foo'/);
t.end();
});

0 comments on commit 75108bc

Please sign in to comment.