Skip to content

Commit

Permalink
Merge pull request #60 from iambumblehead/resolve-issue-affecting-pac…
Browse files Browse the repository at this point in the history
…kage-resolution

Resolve issue affecting package resolution
  • Loading branch information
iambumblehead authored Oct 15, 2023
2 parents c244cad + 7829143 commit 1274be5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
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

0 comments on commit 1274be5

Please sign in to comment.