mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-12-19 11:32:18 -06:00
feat: cli v0.2.0
This commit is contained in:
35
lib/utils/verifyPm2Installation.js
Normal file
35
lib/utils/verifyPm2Installation.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { exec } = require('child_process');
|
||||
|
||||
module.exports = async (install = false) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec('pm2 -v', async (err) => {
|
||||
if (err) {
|
||||
console.log('⚙️ PM2 is not installed')
|
||||
if (!install) return reject(false)
|
||||
const installSuccess = await installPM2()
|
||||
if (!installSuccess) return reject(false)
|
||||
resolve(true)
|
||||
}
|
||||
console.log('⚙️ PM2 is installed')
|
||||
resolve(true)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function installPM2() {
|
||||
return new Promise((resolve) => {
|
||||
console.log('⚙️ Installing PM2...')
|
||||
console.time('⚙️ PM2 installed successfully')
|
||||
exec('npm install -g pm2', (err, stdout) => {
|
||||
console.timeEnd('⚙️ PM2 installed successfully')
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return resolve(false)
|
||||
}
|
||||
console.log(stdout)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user