-
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
da796f2
commit e6f1af1
Showing
3 changed files
with
44 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const isESMApp = require('./esm').isESMApp; | ||
|
||
exports.getPackageInstallation = function getPackageInstallation() { | ||
const instrumentationMap = { | ||
usingExperimentalLoaderFlag: '--experimental-loader flag', | ||
usingImport: '--import flag', | ||
usingRequire: '--require flag', | ||
noFlags: 'no additional flags' | ||
}; | ||
let method = ''; | ||
|
||
if (isESMApp()) { | ||
const usingExperimentalLoaderFlag = | ||
process.env.NODE_OPTIONS?.includes('--experimental-loader') | ||
|| process.execArgv?.[0]?.includes('--experimental-loader') | ||
? 'usingExperimentalLoaderFlag' : ''; | ||
const usingImportFlag = | ||
process.env.NODE_OPTIONS?.includes('--import') || process.execArgv?.[0]?.includes('--import') | ||
? 'usingImport' : ''; | ||
method = instrumentationMap[usingExperimentalLoaderFlag || usingImportFlag || 'noFlags']; | ||
} else { | ||
const usingRequire = | ||
(process.env.NODE_OPTIONS?.includes('--require') && process.env.NODE_OPTIONS?.includes('@instana')) || | ||
(process.execArgv?.[0]?.includes('--require') && process.execArgv?.[0].includes('@instana')) || | ||
(process.execArgv?.[0]?.includes('--require') && process.execArgv?.[1].includes('@instana')) | ||
? 'usingRequire' : ''; | ||
method = instrumentationMap[usingRequire || 'noFlags']; | ||
} | ||
|
||
return method; | ||
}; |
This file was deleted.
Oops, something went wrong.