-
Notifications
You must be signed in to change notification settings - Fork 36
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
c01e2d2
commit 5338879
Showing
4 changed files
with
38 additions
and
3 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 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
30 changes: 30 additions & 0 deletions
30
packages/collector/test/tracing/control_flow/pubsub_async_iterator/mockVersion.js
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,30 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const mock = require('mock-require'); | ||
const hook = require('../../../../../core/src/util/hook'); | ||
|
||
const GRAPHQL_SUBSCRIPTIONS_VERSION = process.env.GRAPHQL_SUBSCRIPTIONS_VERSION; | ||
const GRAPHQL_SUBSCRIPTIONS_REQUIRE = | ||
process.env.GRAPHQL_SUBSCRIPTIONS_VERSION === 'latest' | ||
? 'graphql-subscriptions' | ||
: `graphql-subscriptions-${GRAPHQL_SUBSCRIPTIONS_VERSION}`; | ||
|
||
if (GRAPHQL_SUBSCRIPTIONS_REQUIRE !== 'graphql-subscriptions') { | ||
mock('graphql-subscriptions', GRAPHQL_SUBSCRIPTIONS_REQUIRE); | ||
} | ||
|
||
const originalOnFileLoad = hook.onFileLoad; | ||
hook.onFileLoad = function onFileLoad() { | ||
if (arguments[0].source === '\\/graphql-subscriptions\\/dist\\/pubsub-async-iterator\\.js') { | ||
const str = arguments[0].source.replace('graphql-subscriptions', GRAPHQL_SUBSCRIPTIONS_REQUIRE); | ||
const reg = new RegExp(str, ''); | ||
arguments[0] = reg; | ||
return originalOnFileLoad.apply(this, arguments); | ||
} | ||
|
||
return originalOnFileLoad.apply(this, arguments); | ||
}; |
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