Skip to content

Commit

Permalink
Fix SDK Already Exists Check for Linux (#1235)
Browse files Browse the repository at this point in the history
* Handle Linux environments when checking if the agent attached already.

* Update package-lock.json
  • Loading branch information
JacksonWeber authored Oct 27, 2023
1 parent 11c70da commit 892bbb1
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 75 deletions.
11 changes: 9 additions & 2 deletions Bootstrap/Helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { DiagnosticLog, DiagnosticMessageId } from "./DataModel";
import { DiagnosticLogger } from "./DiagnosticLogger";
import { isWindows, isLinux } from "../Library/PrefixHelper";

export function sdkAlreadyExists(_logger: DiagnosticLogger): boolean {
try {
// appInstance should either resolve to user SDK or crash. If it resolves to attach SDK, user probably modified their NODE_PATH
let appInstance: string;
try {
// Node 8.9+
appInstance = (require.resolve as any)("applicationinsights", { paths: [process.cwd()] });
// Node 8.9+ Windows
if (isWindows()) {
appInstance = (require.resolve as any)("applicationinsights", { paths: [process.cwd()] });
}
// Node 8.9+ Linux
else if (isLinux()) {
appInstance = `${process.cwd()}${(require.resolve as any)("applicationinsights", { paths: [process.cwd()] })}`;
}
} catch (e) {
// Node <8.9
appInstance = require.resolve(process.cwd() + "/node_modules/applicationinsights");
Expand Down
188 changes: 115 additions & 73 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 892bbb1

Please sign in to comment.