-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fd0f86
commit 3d8fd44
Showing
3 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import path from 'path' | ||
|
||
async function resolve(url, context, defaultResolve) { | ||
// To avoid circular dependencies | ||
// We suppose that all the verifiers include "verify" in the name | ||
if ( | ||
typeof context.parentURL !== 'undefined' && | ||
context.parentURL.includes('verify') | ||
) { | ||
return defaultResolve(url, context, defaultResolve) | ||
} | ||
|
||
const modulesToPatch = { | ||
'node:test': './test.verify.js', | ||
'node:assert': './assert.verify.js', | ||
// We're always mocking the src in order to spy the calls | ||
'../src/index.js': path.join(process.cwd(), 'verifiers', 'index.verify.js') | ||
} | ||
|
||
if (Object.keys(modulesToPatch).includes(url)) { | ||
return defaultResolve( | ||
new URL(modulesToPatch[url], import.meta.url).href, | ||
context, | ||
defaultResolve | ||
) | ||
} | ||
|
||
// For all other modules, use the default loader | ||
return defaultResolve(url, context, defaultResolve) | ||
} | ||
|
||
export { resolve } |