From 548cadfdf3414bbe315028e302ba7344d52a4b37 Mon Sep 17 00:00:00 2001 From: Daniel Morgenstern Date: Mon, 8 Oct 2018 15:39:01 +0200 Subject: [PATCH] reformat cli.js to run under node --- cli.js | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/cli.js b/cli.js index efb7dcb..6008623 100644 --- a/cli.js +++ b/cli.js @@ -5,40 +5,24 @@ const path = require('path'); const pm2Config = require('./pm2.config'); const port = pm2Config.serveUIStatic.env.PM2_SERVE_PORT; const logFiles = { - ui: path.join( - __dirname, - pm2Config.runServer.cwd || '', - pm2Config.runServer.log, - ), - server: path.join( - __dirname, - pm2Config.serveUIStatic.cwd || '', - pm2Config.serveUIStatic.log, - ), + ui: path.join(__dirname, pm2Config.runServer.cwd || '', pm2Config.runServer.log), + server: path.join(__dirname, pm2Config.serveUIStatic.cwd || '', pm2Config.serveUIStatic.log), }; const programm = 'npmfrog'; const firstArg = process.argv[2]; const command = firstArg === 'stop' ? 'stop' : 'start'; -exec( - `npm ${command}`, - { - cwd: __dirname, - }, - (error, stdout, stderr) => { - console.log(`${stdout}`); - console.error(`${stderr}`); - if (command === 'start') { - console.log(`Running npmFrog in background on http://localhost:${port}`); - console.log(`To stop npmFrog, run \`${programm} stop\``); - console.log( - `Logs can be found in ${logFiles.server} and ${logFiles.ui} .`, - ); - } else if (command === 'stop') { - console.log(`Stopped npmFrog.`); - } - if (error !== null) { - console.error(`npmFrog error: ${error}`); - } - }, -); +exec(`npm ${command}`, { cwd: __dirname }, (error, stdout, stderr) => { + console.log(`${stdout}`); + console.error(`${stderr}`); + if (command === 'start') { + console.log(`Running npmFrog in background on http://localhost:${port}`); + console.log(`To stop npmFrog, run \`${programm} stop\``); + console.log(`Logs can be found in ${logFiles.server} and ${logFiles.ui} .`); + } else if (command === 'stop') { + console.log(`Stopped npmFrog.`); + } + if (error !== null) { + console.error(`npmFrog error: ${error}`); + } +});