feat: cli v0.2.0

This commit is contained in:
Gabriel Pastori
2023-11-14 11:38:22 -03:00
parent 5e0c55b489
commit b6f447bb0a
16 changed files with 1297 additions and 7 deletions

View 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)
})
})
}