Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/node-modules-paths.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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();
});