Skip to content

Commit e007774

Browse files
committed
otel install fix
1 parent 61a1142 commit e007774

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

lib/OtelManager.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var path = require('path')
44
var execSync = require('child_process').execSync
55
var Common = require('./Common')
66
var cst = require('../constants')
7+
var which = require('./tools/which')
78

89
var PM2_ROOT = path.join(__dirname, '..')
910

@@ -29,17 +30,25 @@ module.exports = {
2930
},
3031

3132
install: function() {
33+
var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null
34+
if (!pm) {
35+
throw new Error('npm or bun is required to install OpenTelemetry packages')
36+
}
3237
Common.printOut(cst.PREFIX_MSG + 'Installing OpenTelemetry tracing packages...')
33-
execSync('npm install --no-save ' + OTEL_PACKAGES.join(' '), {
38+
execSync(pm + ' install --no-save ' + OTEL_PACKAGES.join(' '), {
3439
cwd: PM2_ROOT,
3540
stdio: 'inherit'
3641
})
3742
Common.printOut(cst.PREFIX_MSG + 'OpenTelemetry tracing packages installed successfully')
3843
},
3944

4045
uninstall: function() {
46+
var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null
47+
if (!pm) {
48+
throw new Error('npm or bun is required to uninstall OpenTelemetry packages')
49+
}
4150
Common.printOut(cst.PREFIX_MSG + 'Removing OpenTelemetry tracing packages...')
42-
execSync('npm uninstall --no-save ' + OTEL_PACKAGES.join(' '), {
51+
execSync(pm + ' remove --no-save ' + OTEL_PACKAGES.join(' '), {
4352
cwd: PM2_ROOT,
4453
stdio: 'inherit'
4554
})

0 commit comments

Comments
 (0)