Skip to content

Commit

Permalink
Add require check for path resolver
Browse files Browse the repository at this point in the history
Closes #35.
  • Loading branch information
niksy committed Nov 20, 2024
1 parent 0d7399d commit 26208c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Pin `domain-browser` to 4.22.0
- Add `require` check for path resolver

## [1.2.1][] - 2024-09-16

Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ import pkgDir from 'pkg-dir';
* @param {string} path
*/
const resolvePath = (path) => {

Check warning on line 7 in index.js

View workflow job for this annotation

GitHub Actions / Test (10)

'path' is already declared in the upper scope on line 44 column 7

Check warning on line 7 in index.js

View workflow job for this annotation

GitHub Actions / Test (12)

'path' is already declared in the upper scope on line 44 column 7

Check warning on line 7 in index.js

View workflow job for this annotation

GitHub Actions / Test (16)

'path' is already declared in the upper scope on line 44 column 7
let _require = null;
try {
_require = require;
} catch {
// Handled
}
const resolvedPath = (
globalThis.require ?? createRequire(import.meta.url)
_require ??
globalThis.require ??
createRequire(import.meta.url)
).resolve(path);
if (!path.includes('./')) {
const directory = pkgDir.sync(resolvedPath) ?? '';
Expand Down

0 comments on commit 26208c0

Please sign in to comment.