Skip to content

correctly resolve paths that are on networked drives #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2019
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
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {

return paths.reduce(function (dirs, aPath) {
return dirs.concat(modules.map(function (moduleDir) {
return path.join(prefix, aPath, moduleDir);
return path.resolve(prefix, aPath, moduleDir);
}));
}, []);
};
Expand Down
22 changes: 22 additions & 0 deletions test/node-modules-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,26 @@ test('node-modules-paths', function (t) {

t.end();
});

t.test('combine paths correctly on Windows', function (t) {
var start = 'C:\\Users\\username\\myProject\\src';
var paths = [];
var moduleDirectories = ['node_modules', start];
var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories });

t.equal(dirs.indexOf(path.resolve(start)) > -1, true, 'should contain start dir');

t.end();
});

t.test('combine paths correctly on non-Windows', { skip: process.platform === 'win32' }, function (t) {
var start = '/Users/username/git/myProject/src';
var paths = [];
var moduleDirectories = ['node_modules', '/Users/username/git/myProject/src'];
var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories });

t.equal(dirs.indexOf(path.resolve(start)) > -1, true, 'should contain start dir');

t.end();
});
});