Skip to content

Commit

Permalink
fix: Traverse symlinks for configPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Kellen authored and phated committed Nov 22, 2021
1 parent 6e686fb commit dfd9f24
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.13.3:
date: 2014-10-06
changes:
- Return the real location of symlinked config files.
v0.13.2:
date: 2014-09-12
changes:
Expand Down
3 changes: 2 additions & 1 deletion lib/find_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = function (opts) {
}
// confirm the configPath exists and return an absolute path to it
if (fs.existsSync(configPath)) {
return path.resolve(configPath);
// traverse symlinks if needed
return fs.realpathSync(path.resolve(configPath));
}
return null;
};
1 change: 1 addition & 0 deletions test/fixtures/symlink/mochafile.js
7 changes: 7 additions & 0 deletions test/lib/find_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ describe('findConfig', function () {
})).to.equal(path.resolve('test/fixtures/search_path/mochafile.js'));
});

it('should traverse symlinks', function () {
expect(findConfig({
configNameSearch: ['mochafile.js'],
searchPaths: ['test/fixtures/symlink']
})).to.equal(path.resolve('test/fixtures/mochafile.js'));
});

});

0 comments on commit dfd9f24

Please sign in to comment.