From a40d85173f48cee93330672eb1276505a6645783 Mon Sep 17 00:00:00 2001 From: Hans Ott Date: Thu, 28 Nov 2024 12:46:39 +0100 Subject: [PATCH] Use __ prefix for function --- library/agent/hooks/wrapRequire.ts | 6 ++++-- library/helpers/startTestAgent.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/library/agent/hooks/wrapRequire.ts b/library/agent/hooks/wrapRequire.ts index c648a069..c8a78cd8 100644 --- a/library/agent/hooks/wrapRequire.ts +++ b/library/agent/hooks/wrapRequire.ts @@ -309,12 +309,14 @@ export function getOriginalRequire() { // In order to support multiple versions of the same package, we need to rewrite the package name // e.g. In our sources and sinks, we use the real package name `hooks.addPackage("undici")` // but in the tests we want to `require("undici-v6")` instead of `require("undici")` -export function rewritePackageName( +export function __internalRewritePackageName( packageName: string, aliasForTesting: string ) { if (!isRequireWrapped) { - throw new Error("Start the agent before calling rewritePackageName(..)"); + throw new Error( + "Start the agent before calling __internalRewritePackageName(..)" + ); } if (packages.length === 0) { diff --git a/library/helpers/startTestAgent.ts b/library/helpers/startTestAgent.ts index cae9a1a1..a16483e0 100644 --- a/library/helpers/startTestAgent.ts +++ b/library/helpers/startTestAgent.ts @@ -1,6 +1,6 @@ import type { ReportingAPI } from "../agent/api/ReportingAPI"; import type { Token } from "../agent/api/Token"; -import { rewritePackageName } from "../agent/hooks/wrapRequire"; +import { __internalRewritePackageName } from "../agent/hooks/wrapRequire"; import type { Logger } from "../agent/logger/Logger"; import { Wrapper } from "../agent/Wrapper"; import { createTestAgent } from "./createTestAgent"; @@ -28,7 +28,7 @@ export function startTestAgent(opts: { // but in the tests we want to `require("undici-v6")` instead of `require("undici")` // The `__internalRewritePackageName` function allows us to do this Object.keys(opts.rewrite).forEach((packageName) => { - rewritePackageName(packageName, opts.rewrite[packageName]); + __internalRewritePackageName(packageName, opts.rewrite[packageName]); }); return agent;