Skip to content

Commit

Permalink
feat: Warn on multiple hook initialization (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish authored Dec 4, 2024
1 parent 12be30b commit 9bd539e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ function createHook (meta) {
let includeModules, excludeModules

async function initialize (data) {
if (global.__import_in_the_middle_initialized__) {
process.emitWarning("The 'import-in-the-middle' hook has already been initialized")
}

global.__import_in_the_middle_initialized__ = true

if (data) {
includeModules = ensureArrayWithBareSpecifiersFileUrlsAndRegex(data.include, 'include')
excludeModules = ensureArrayWithBareSpecifiersFileUrlsAndRegex(data.exclude, 'exclude')
Expand Down

0 comments on commit 9bd539e

Please sign in to comment.