Skip to content

Commit

Permalink
fix(module): dont resolve path is starts with #
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Mar 23, 2023
1 parent 8ce4299 commit d622472
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/common",
"version": "3.4.5",
"version": "3.4.6",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class Module {

path = splited[0]

if (extname(path)) {
if (!path.startsWith('#') && extname(path)) {
path = resolve(path)
}

Expand Down
10 changes: 10 additions & 0 deletions tests/Stubs/controllers/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @athenna/common
*
* (c) João Lenon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

export class AppController {}
6 changes: 6 additions & 0 deletions tests/Unit/ModuleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ test.group('ModuleTest', () => {
assert.equal(Exception.name, 'Exception')
})

test('should be able to resolve import alias with dots in the path by meta url and import it', async ({ assert }) => {
const AppController = await Module.resolve('#tests/Stubs/controllers/app.controller', import.meta.url)

assert.equal(AppController.name, 'AppController')
})

test('should be able to resolve partial paths by meta url and import it', async ({ assert }) => {
const Exception = await Module.resolve('./src/Helpers/Exception.js', import.meta.url)

Expand Down

0 comments on commit d622472

Please sign in to comment.