From 56e2ba3e9b4b858e385369472cc7e84ff027eccc Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 00:24:59 -0700 Subject: [PATCH 1/6] resolve issue affecting package resolution --- package.json | 2 +- resolvewithplus.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 20b849f..9f5ec7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "resolvewithplus", - "version": "2.0.8", + "version": "2.0.9", "description": "resolvewith with extra power", "readmeFilename": "README.md", "license": "ISC", diff --git a/resolvewithplus.js b/resolvewithplus.js index 4657ea3..e598c2d 100644 --- a/resolvewithplus.js +++ b/resolvewithplus.js @@ -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 From 9c175d8bc87048b272b47cf1fe849a3ee4e60a01 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 07:49:18 -0700 Subject: [PATCH 2/6] added test --- tests/tests-basic/tests-basic.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/tests-basic/tests-basic.test.js b/tests/tests-basic/tests-basic.test.js index 613cad2..cb0aa88 100644 --- a/tests/tests-basic/tests-basic.test.js +++ b/tests/tests-basic/tests-basic.test.js @@ -245,6 +245,15 @@ 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 pathsToLook = resolvewithplus.getasnode_module_paths(fullpath) + const returnedPath = '/root/node_modules/gani/node_modules' + .replace(/\//g, path.sep) + + assert.ok(pathsToLook.some(path => path === returnedPath)) +}) + test('should handle exports.import path definition', () => { assert.strictEqual(resolvewithplus.gettargetindex({ name: 'test', From 4eb360319c346d282a576f551744ca80a23bbf18 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 07:57:10 -0700 Subject: [PATCH 3/6] add console.log for failing windows test --- tests/tests-basic/tests-basic.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests-basic/tests-basic.test.js b/tests/tests-basic/tests-basic.test.js index cb0aa88..6cffe90 100644 --- a/tests/tests-basic/tests-basic.test.js +++ b/tests/tests-basic/tests-basic.test.js @@ -251,6 +251,8 @@ test('getasnode_module_paths, no missed path isresolvewithpath test', () => { const returnedPath = '/root/node_modules/gani/node_modules' .replace(/\//g, path.sep) + console.log(pathsToLook, returnedPath) + assert.ok(pathsToLook.some(path => path === returnedPath)) }) From 6158b67acc20deb797cf912af64f1c36f03a32a2 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 08:06:10 -0700 Subject: [PATCH 4/6] use string includes to check --- tests/tests-basic/tests-basic.test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tests-basic/tests-basic.test.js b/tests/tests-basic/tests-basic.test.js index 6cffe90..14a57b6 100644 --- a/tests/tests-basic/tests-basic.test.js +++ b/tests/tests-basic/tests-basic.test.js @@ -251,9 +251,7 @@ test('getasnode_module_paths, no missed path isresolvewithpath test', () => { const returnedPath = '/root/node_modules/gani/node_modules' .replace(/\//g, path.sep) - console.log(pathsToLook, returnedPath) - - assert.ok(pathsToLook.some(path => path === returnedPath)) + assert.ok(pathsToLook.some(path => path.includes(returnedPath))) }) test('should handle exports.import path definition', () => { From ef61a64f91751847eaa4a1674bdf3463fd81cd25 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 08:14:08 -0700 Subject: [PATCH 5/6] update test for different path separators --- tests/tests-basic/tests-basic.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/tests-basic/tests-basic.test.js b/tests/tests-basic/tests-basic.test.js index 14a57b6..21519ad 100644 --- a/tests/tests-basic/tests-basic.test.js +++ b/tests/tests-basic/tests-basic.test.js @@ -247,11 +247,15 @@ 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 pathsToLook = resolvewithplus.getasnode_module_paths(fullpath) - const returnedPath = '/root/node_modules/gani/node_modules' - .replace(/\//g, path.sep) + 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) - assert.ok(pathsToLook.some(path => path.includes(returnedPath))) + // 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', () => { From 7829143229569a1aaa4ddb76c7799135c3c98eaf Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 15 Oct 2023 08:23:08 -0700 Subject: [PATCH 6/6] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6952197..a8accbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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_