Skip to content

Commit

Permalink
Use __ prefix for function
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Nov 28, 2024
1 parent ff82e02 commit a40d851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions library/agent/hooks/wrapRequire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions library/helpers/startTestAgent.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a40d851

Please sign in to comment.