Skip to content
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

Resolve issue affecting package resolution #60

Merged
merged 6 commits into from
Oct 15, 2023
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# changelog

* 2.0.9 _Oct.15.2023_
* [resolve error preventing](https://github.com/iambumblehead/resolvewithplus/pull/60) module resolution. There is a condition that alters lookup paths for the situation when resolvewithplus is being developed and tested from inside another package's node_modules. The condition caused lookup errors. The condition was changed and a unit-test added
* 2.0.8 _Oct.06.2023_
* [remove un-necessary sorting](https://github.com/iambumblehead/resolvewithplus/pull/59) should result in faster lookups
* 2.0.7 _Oct.06.2023_
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resolvewithplus",
"version": "2.0.8",
"version": "2.0.9",
"description": "resolvewith with extra power",
"readmeFilename": "README.md",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion resolvewithplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getasnode_module_paths = (start, parts = start.split(path.sep)) => {

// the second condition allow resolvewithplus unit-tests to pass,
// when resolvewithplus is inside another package's node_modules
if (parts[0] === node_modules && !isResolveWithPathRe.test(start))
if (parts[0] === node_modules && isResolveWithPathRe.test(start))
return next_module_paths(parts.slice(1), tuple)

// windows and linux paths split differently
Expand Down
13 changes: 13 additions & 0 deletions tests/tests-basic/tests-basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ test('getasnode_module_paths, should return paths to node_modules', () => {
}
})

test('getasnode_module_paths, no missed path isresolvewithpath test', () => {
const fullpath = '/root/node_modules/gani/src/'
const fullpathOS = fullpath.replace(/\//g, path.sep)
const expectedPath = '/root/node_modules/gani/node_modules'
const expectedPathOS = expectedPath.replace(/\//g, path.sep)

const pathsToLook = resolvewithplus.getasnode_module_paths(fullpathOS)

// windows paths may start "C:\\root\node_modules"
// so use String.includes rather than strict equality comparison
assert.ok(pathsToLook.some(path => path.includes(expectedPathOS)))
})

test('should handle exports.import path definition', () => {
assert.strictEqual(resolvewithplus.gettargetindex({
name: 'test',
Expand Down