From afbf398313a4426de79797524e47eaa47c793f6c Mon Sep 17 00:00:00 2001 From: AYOKINYA Date: Fri, 25 Oct 2024 10:58:26 +0900 Subject: [PATCH] fix: Update TAR.package to TAR.packager in Modularizer.js The package function in TAR.js was renamed to packager for ES6 strict mode compatibility (#5680), but the reference in Modularizer.js was not updated accordingly. --- lib/API/Modules/Modularizer.js | 158 ++++++------ lib/API/Modules/TAR.js | 441 ++++++++++++++++++--------------- 2 files changed, 326 insertions(+), 273 deletions(-) diff --git a/lib/API/Modules/Modularizer.js b/lib/API/Modules/Modularizer.js index 614e6e71b2..ebb65568c7 100644 --- a/lib/API/Modules/Modularizer.js +++ b/lib/API/Modules/Modularizer.js @@ -3,25 +3,25 @@ * Use of this source code is governed by a license that * can be found in the LICENSE file. */ -var path = require('path'); -var eachLimit = require('async/eachLimit'); -var forEachLimit = require('async/forEachLimit'); +var path = require("path"); +var eachLimit = require("async/eachLimit"); +var forEachLimit = require("async/forEachLimit"); -var Configuration = require('../../Configuration.js'); -var cst = require('../../../constants.js'); -var Common = require('../../Common'); -var NPM = require('./NPM.js') -var TAR = require('./TAR.js') -var LOCAL = require('./LOCAL.js') +var Configuration = require("../../Configuration.js"); +var cst = require("../../../constants.js"); +var Common = require("../../Common"); +var NPM = require("./NPM.js"); +var TAR = require("./TAR.js"); +var LOCAL = require("./LOCAL.js"); -var Modularizer = module.exports = {}; +var Modularizer = (module.exports = {}); /** * PM2 Module System. */ Modularizer.install = function (CLI, module_name, opts, cb) { module_name = module_name.replace(/[;`|]/g, ""); - if (typeof(opts) == 'function') { + if (typeof opts == "function") { cb = opts; opts = {}; } @@ -29,23 +29,20 @@ Modularizer.install = function (CLI, module_name, opts, cb) { if (LOCAL.INTERNAL_MODULES.hasOwnProperty(module_name)) { Common.logMod(`Adding dependency ${module_name} to PM2 Runtime`); var currentModule = LOCAL.INTERNAL_MODULES[module_name]; - if (currentModule && currentModule.hasOwnProperty('dependencies')) { + if (currentModule && currentModule.hasOwnProperty("dependencies")) { LOCAL.installMultipleModules(currentModule.dependencies, cb); } else { LOCAL.install(currentModule, cb); } - } - else if (module_name == '.') { + } else if (module_name == ".") { Common.logMod(`Installing local NPM module`); - return NPM.localStart(CLI, opts, cb) - } - else if (opts.tarball || /\.tar\.gz$/i.test(module_name)) { + return NPM.localStart(CLI, opts, cb); + } else if (opts.tarball || /\.tar\.gz$/i.test(module_name)) { Common.logMod(`Installing TAR module`); - TAR.install(CLI, module_name, opts, cb) - } - else { + TAR.install(CLI, module_name, opts, cb); + } else { Common.logMod(`Installing NPM ${module_name} module`); - NPM.install(CLI, module_name, opts, cb) + NPM.install(CLI, module_name, opts, cb); } }; @@ -53,96 +50,113 @@ Modularizer.install = function (CLI, module_name, opts, cb) { * Launch All Modules * Used PM2 at startup */ -Modularizer.launchModules = function(CLI, cb) { +Modularizer.launchModules = function (CLI, cb) { var modules = Modularizer.listModules(); if (!modules) return cb(); // 1# function launchNPMModules(cb) { - if (!modules.npm_modules) return launchTARModules(cb) - - eachLimit(Object.keys(modules.npm_modules), 1, function(module_name, next) { - NPM.start(CLI, modules, module_name, next) - }, function() { - launchTARModules(cb) - }); + if (!modules.npm_modules) return launchTARModules(cb); + + eachLimit( + Object.keys(modules.npm_modules), + 1, + function (module_name, next) { + NPM.start(CLI, modules, module_name, next); + }, + function () { + launchTARModules(cb); + } + ); } // 2# function launchTARModules(cb) { - if (!modules.tar_modules) return cb() - - eachLimit(Object.keys(modules.tar_modules), 1, function(module_name, next) { - TAR.start(CLI, module_name, next) - }, function() { - return cb ? cb(null) : false; - }); + if (!modules.tar_modules) return cb(); + + eachLimit( + Object.keys(modules.tar_modules), + 1, + function (module_name, next) { + TAR.start(CLI, module_name, next); + }, + function () { + return cb ? cb(null) : false; + } + ); } - launchNPMModules(cb) -} + launchNPMModules(cb); +}; -Modularizer.package = function(CLI, module_path, cb) { - var fullpath = process.cwd() - if (module_path) - fullpath = require('path').resolve(module_path) - TAR.package(fullpath, process.cwd(), cb) -} +Modularizer.package = function (CLI, module_path, cb) { + var fullpath = process.cwd(); + if (module_path) fullpath = require("path").resolve(module_path); + TAR.packager(fullpath, process.cwd(), cb); +}; /** * Uninstall module */ -Modularizer.uninstall = function(CLI, module_name, cb) { - Common.printOut(cst.PREFIX_MSG_MOD + 'Uninstalling module ' + module_name); +Modularizer.uninstall = function (CLI, module_name, cb) { + Common.printOut(cst.PREFIX_MSG_MOD + "Uninstalling module " + module_name); var modules_list = Modularizer.listModules(); - if (module_name == 'all') { + if (module_name == "all") { if (!modules_list) return cb(); - return forEachLimit(Object.keys(modules_list.npm_modules), 1, function(module_name, next) { - NPM.uninstall(CLI, module_name, next) - }, () => { - forEachLimit(Object.keys(modules_list.tar_modules), 1, function(module_name, next) { - TAR.uninstall(CLI, module_name, next) - }, cb) - }); + return forEachLimit( + Object.keys(modules_list.npm_modules), + 1, + function (module_name, next) { + NPM.uninstall(CLI, module_name, next); + }, + () => { + forEachLimit( + Object.keys(modules_list.tar_modules), + 1, + function (module_name, next) { + TAR.uninstall(CLI, module_name, next); + }, + cb + ); + } + ); } if (modules_list.npm_modules[module_name]) { - NPM.uninstall(CLI, module_name, cb) + NPM.uninstall(CLI, module_name, cb); } else if (modules_list.tar_modules[module_name]) { - TAR.uninstall(CLI, module_name, cb) - } - else { - Common.errMod('Unknown module') - CLI.exitCli(1) + TAR.uninstall(CLI, module_name, cb); + } else { + Common.errMod("Unknown module"); + CLI.exitCli(1); } }; /** * List modules based on modules present in ~/.pm2/modules/ folder */ -Modularizer.listModules = function() { +Modularizer.listModules = function () { return { npm_modules: Configuration.getSync(cst.MODULE_CONF_PREFIX) || {}, - tar_modules: Configuration.getSync(cst.MODULE_CONF_PREFIX_TAR) || {} - } + tar_modules: Configuration.getSync(cst.MODULE_CONF_PREFIX_TAR) || {}, + }; }; -Modularizer.getAdditionalConf = function(app_name) { - return NPM.getModuleConf(app_name) +Modularizer.getAdditionalConf = function (app_name) { + return NPM.getModuleConf(app_name); }; -Modularizer.publish = function(PM2, folder, opts, cb) { +Modularizer.publish = function (PM2, folder, opts, cb) { if (opts.npm == true) { - NPM.publish(opts, cb) - } - else { - TAR.publish(PM2, folder, cb) + NPM.publish(opts, cb); + } else { + TAR.publish(PM2, folder, cb); } }; -Modularizer.generateSample = function(app_name, cb) { - NPM.generateSample(app_name, cb) +Modularizer.generateSample = function (app_name, cb) { + NPM.generateSample(app_name, cb); }; diff --git a/lib/API/Modules/TAR.js b/lib/API/Modules/TAR.js index 1cd223f88c..540f68b836 100644 --- a/lib/API/Modules/TAR.js +++ b/lib/API/Modules/TAR.js @@ -1,25 +1,24 @@ - -var Configuration = require('../../Configuration.js'); -var cst = require('../../../constants.js'); -var Common = require('../../Common'); -var forEachLimit = require('async/forEachLimit'); -const sexec = require('../../tools/sexec.js'); -const deleteFolderRecursive = require('../../tools/deleteFolderRecursive.js'); - -var path = require('path'); -var fs = require('fs'); -var os = require('os'); -var spawn = require('child_process').spawn; -var exec = require('child_process').exec; -var execSync = require('child_process').execSync; +var Configuration = require("../../Configuration.js"); +var cst = require("../../../constants.js"); +var Common = require("../../Common"); +var forEachLimit = require("async/forEachLimit"); +const sexec = require("../../tools/sexec.js"); +const deleteFolderRecursive = require("../../tools/deleteFolderRecursive.js"); + +var path = require("path"); +var fs = require("fs"); +var os = require("os"); +var spawn = require("child_process").spawn; +var exec = require("child_process").exec; +var execSync = require("child_process").execSync; module.exports = { install, uninstall, start, publish, - packager -} + packager, +}; /** * Module management to manage tarball packages @@ -33,172 +32,182 @@ module.exports = { function install(PM2, module_filepath, opts, cb) { // Remote file retrieval - if (module_filepath.includes('http') === true) { - var target_file = module_filepath.split('/').pop() - var target_filepath = path.join(os.tmpdir(), target_file) + if (module_filepath.includes("http") === true) { + var target_file = module_filepath.split("/").pop(); + var target_filepath = path.join(os.tmpdir(), target_file); - opts.install_url = module_filepath + opts.install_url = module_filepath; return retrieveRemote(module_filepath, target_filepath, (err) => { if (err) { - Common.errMod(err) - process.exit(1) + Common.errMod(err); + process.exit(1); } - installLocal(PM2, target_filepath, opts, cb) - }) + installLocal(PM2, target_filepath, opts, cb); + }); } // Local install - installLocal(PM2, module_filepath, opts, cb) + installLocal(PM2, module_filepath, opts, cb); } function retrieveRemote(url, dest, cb) { - Common.logMod(`Retrieving remote package ${url}...`) + Common.logMod(`Retrieving remote package ${url}...`); - var wget = spawn('wget', [url, '-O', dest, '-q'], { - stdio : 'inherit', + var wget = spawn("wget", [url, "-O", dest, "-q"], { + stdio: "inherit", env: process.env, windowsHide: true, - shell : true - }) - - wget.on('error', (err) => { - console.error(err.stack || err) - }) - - wget.on('close', (code) => { - if (code !== 0) - return cb(new Error('Could not download')) - return cb(null) - }) + shell: true, + }); + + wget.on("error", (err) => { + console.error(err.stack || err); + }); + + wget.on("close", (code) => { + if (code !== 0) return cb(new Error("Could not download")); + return cb(null); + }); } function installLocal(PM2, module_filepath, opts, cb) { - Common.logMod(`Installing package ${module_filepath}`) + Common.logMod(`Installing package ${module_filepath}`); // Get module name by unpacking the module/package.json only and read the name attribute - getModuleName(module_filepath, function(err, module_name) { - if (err) return cb(err) + getModuleName(module_filepath, function (err, module_name) { + if (err) return cb(err); - Common.logMod(`Module name is ${module_name}`) + Common.logMod(`Module name is ${module_name}`); - Common.logMod(`Depackaging module...`) + Common.logMod(`Depackaging module...`); var install_path = path.join(cst.DEFAULT_MODULE_PATH, module_name); - require('mkdirp').sync(install_path) + require("mkdirp").sync(install_path); - var install_instance = spawn('tar', ['zxf', module_filepath, '-C', install_path, '--strip-components 1'], { - stdio : 'inherit', - env: process.env, - shell : true - }) + var install_instance = spawn( + "tar", + ["zxf", module_filepath, "-C", install_path, "--strip-components 1"], + { + stdio: "inherit", + env: process.env, + shell: true, + } + ); - install_instance.on('close', function(code) { - Common.logMod(`Module depackaged in ${install_path}`) + install_instance.on("close", function (code) { + Common.logMod(`Module depackaged in ${install_path}`); if (code == 0) - return runInstall(PM2, install_path, module_name, opts, cb) - return PM2.exitCli(1) + return runInstall(PM2, install_path, module_name, opts, cb); + return PM2.exitCli(1); }); - install_instance.on('error', function (err) { + install_instance.on("error", function (err) { console.error(err.stack || err); }); - }) + }); } function deleteModulePath(module_name) { - var sanitized = module_name.replace(/\./g, '') + var sanitized = module_name.replace(/\./g, ""); deleteFolderRecursive(path.join(cst.DEFAULT_MODULE_PATH, module_name)); } function runInstall(PM2, target_path, module_name, opts, cb) { - var config_file = path.join(target_path, 'package.json') - var conf + var config_file = path.join(target_path, "package.json"); + var conf; try { - conf = require(config_file) - module_name = conf.name - } catch(e) { - Common.errMod(new Error('Cannot find package.json file with name attribute at least')); + conf = require(config_file); + module_name = conf.name; + } catch (e) { + Common.errMod( + new Error("Cannot find package.json file with name attribute at least") + ); } // Force with the name in the package.json - opts.started_as_module = true - opts.cwd = target_path + opts.started_as_module = true; + opts.cwd = target_path; - if (needPrefix(conf)) - opts.name_prefix = module_name + if (needPrefix(conf)) opts.name_prefix = module_name; if (opts.install) { - Common.logMod(`Running YARN install...`) - - sexec(`cd ${target_path} ; yarn install`, {silent: false}, function(code) { - // Start apps under "apps" or "pm2" attribute - Common.logMod(`Starting ${target_path}`) - PM2.start(conf, opts, function(err, data) { - if (err) return cb(err) - - Configuration.setSync(`${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`, { - source: 'tarball', - install_url: opts.install_url, - installed_at: Date.now() - }) - - Common.logMod(`Module INSTALLED and STARTED`) - return cb(null, 'Module installed & Started') - }) - }) - } - else { - PM2.start(conf, opts, function(err, data) { - if (err) return cb(err) + Common.logMod(`Running YARN install...`); + + sexec( + `cd ${target_path} ; yarn install`, + { silent: false }, + function (code) { + // Start apps under "apps" or "pm2" attribute + Common.logMod(`Starting ${target_path}`); + PM2.start(conf, opts, function (err, data) { + if (err) return cb(err); + + Configuration.setSync( + `${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`, + { + source: "tarball", + install_url: opts.install_url, + installed_at: Date.now(), + } + ); + + Common.logMod(`Module INSTALLED and STARTED`); + return cb(null, "Module installed & Started"); + }); + } + ); + } else { + PM2.start(conf, opts, function (err, data) { + if (err) return cb(err); Configuration.setSync(`${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`, { - source: 'tarball', + source: "tarball", install_url: opts.install_url, - installed_at: Date.now() - }) + installed_at: Date.now(), + }); - Common.logMod(`Module INSTALLED and STARTED`) - return cb(null, 'Module installed & Started') - }) + Common.logMod(`Module INSTALLED and STARTED`); + return cb(null, "Module installed & Started"); + }); } } function start(PM2, module_name, cb) { var module_path = path.join(cst.DEFAULT_MODULE_PATH, module_name); - Common.printOut(cst.PREFIX_MSG_MOD + 'Starting TAR module ' + module_name); - var package_json_path = path.join(module_path, 'package.json'); - var module_conf = Configuration.getSync(`${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`) + Common.printOut(cst.PREFIX_MSG_MOD + "Starting TAR module " + module_name); + var package_json_path = path.join(module_path, "package.json"); + var module_conf = Configuration.getSync( + `${cst.MODULE_CONF_PREFIX_TAR}:${module_name}` + ); try { - var conf = require(package_json_path) - } catch(e) { - Common.printError(`Could not find package.json as ${package_json_path}`) - return cb() + var conf = require(package_json_path); + } catch (e) { + Common.printError(`Could not find package.json as ${package_json_path}`); + return cb(); } var opts = {}; - opts.started_as_module = true - opts.cwd = module_path + opts.started_as_module = true; + opts.cwd = module_path; - if (module_conf.install_url) - opts.install_url = module_conf.install_url + if (module_conf.install_url) opts.install_url = module_conf.install_url; - if (needPrefix(conf)) - opts.name_prefix = module_name + if (needPrefix(conf)) opts.name_prefix = module_name; - PM2.start(conf, opts, function(err, data) { + PM2.start(conf, opts, function (err, data) { if (err) { - Common.printError(`Could not start ${module_name} ${module_path}`) - return cb() + Common.printError(`Could not start ${module_name} ${module_path}`); + return cb(); } - Common.printOut(`${cst.PREFIX_MSG_MOD} Module ${module_name} STARTED`) + Common.printOut(`${cst.PREFIX_MSG_MOD} Module ${module_name} STARTED`); return cb(); - }) + }); } /** @@ -208,155 +217,185 @@ function start(PM2, module_name, cb) { function uninstall(PM2, module_name, cb) { var module_path = path.join(cst.DEFAULT_MODULE_PATH, module_name); - Common.logMod(`Removing ${module_name} from auto startup`) + Common.logMod(`Removing ${module_name} from auto startup`); try { - var pkg = require(path.join(module_path, 'package.json')) - } catch(e) { - Common.errMod('Could not retrieve module package.json'); - return cb(e) + var pkg = require(path.join(module_path, "package.json")); + } catch (e) { + Common.errMod("Could not retrieve module package.json"); + return cb(e); } - var apps = pkg.apps || pkg.pm2 + var apps = pkg.apps || pkg.pm2; apps = [].concat(apps); /** * Some time a module can have multiple processes */ - forEachLimit(apps, 1, (app, next) => { - var app_name + forEachLimit( + apps, + 1, + (app, next) => { + var app_name; + + if (!app.name) { + Common.renderApplicationName(app); + } - if (!app.name) { - Common.renderApplicationName(app) + if (apps.length > 1) app_name = `${module_name}:${app.name}`; + else if (apps.length == 1 && pkg.name != apps[0].name) + app_name = `${module_name}:${app.name}`; + else app_name = app.name; + + PM2._operate("deleteProcessId", app_name, () => { + deleteModulePath(module_name); + next(); + }); + }, + () => { + Configuration.unsetSync(`${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`); + cb(null); } - - if (apps.length > 1) - app_name = `${module_name}:${app.name}` - else if (apps.length == 1 && pkg.name != apps[0].name) - app_name = `${module_name}:${app.name}` - else - app_name = app.name - - PM2._operate('deleteProcessId', app_name, () => { - deleteModulePath(module_name) - next() - }) - }, () => { - Configuration.unsetSync(`${cst.MODULE_CONF_PREFIX_TAR}:${module_name}`) - cb(null) - }) + ); } - /** * Uncompress only module/package.json and retrieve the "name" attribute in the package.json */ function getModuleName(module_filepath, cb) { - var tmp_folder = path.join(os.tmpdir(), cst.MODULE_BASEFOLDER) - - var install_instance = spawn('tar', ['zxf', module_filepath, '-C', os.tmpdir(), `${cst.MODULE_BASEFOLDER}/package.json`], { - stdio : 'inherit', - env: process.env, - shell : true - }) + var tmp_folder = path.join(os.tmpdir(), cst.MODULE_BASEFOLDER); + + var install_instance = spawn( + "tar", + [ + "zxf", + module_filepath, + "-C", + os.tmpdir(), + `${cst.MODULE_BASEFOLDER}/package.json`, + ], + { + stdio: "inherit", + env: process.env, + shell: true, + } + ); - install_instance.on('close', function(code) { + install_instance.on("close", function (code) { try { - var pkg = JSON.parse(fs.readFileSync(path.join(tmp_folder, `package.json`))) - return cb(null, pkg.name) - } catch(e) { - return cb(e) + var pkg = JSON.parse( + fs.readFileSync(path.join(tmp_folder, `package.json`)) + ); + return cb(null, pkg.name); + } catch (e) { + return cb(e); } }); } function packager(module_path, target_path, cb) { - var base_folder = path.dirname(module_path) - var module_folder_name = path.basename(module_path) - var pkg = require(path.join(module_path, 'package.json')) - var pkg_name = `${module_folder_name}-v${pkg.version.replace(/\./g, '-')}.tar.gz` - var target_fullpath = path.join(target_path, pkg_name) + var base_folder = path.dirname(module_path); + var module_folder_name = path.basename(module_path); + var pkg = require(path.join(module_path, "package.json")); + var pkg_name = `${module_folder_name}-v${pkg.version.replace( + /\./g, + "-" + )}.tar.gz`; + var target_fullpath = path.join(target_path, pkg_name); - var cmd = `tar zcf ${target_fullpath} -C ${base_folder} --transform 's,${module_folder_name},module,' ${module_folder_name}` + var cmd = `tar zcf ${target_fullpath} -C ${base_folder} --transform 's,${module_folder_name},module,' ${module_folder_name}`; - Common.logMod(`Gziping ${module_path} to ${target_fullpath}`) + Common.logMod(`Gziping ${module_path} to ${target_fullpath}`); var tar = exec(cmd, (err, sto, ste) => { if (err) { - console.log(sto.toString().trim()) - console.log(ste.toString().trim()) + console.error(sto.toString().trim()); + console.error(ste.toString().trim()); } - }) + }); - tar.on('close', function (code) { + tar.on("close", function (code) { cb(code == 0 ? null : code, { package_name: pkg_name, - path: target_fullpath - }) - }) + path: target_fullpath, + }); + }); } function publish(PM2, folder, cb) { - var target_folder = folder ? path.resolve(folder) : process.cwd() + var target_folder = folder ? path.resolve(folder) : process.cwd(); try { - var pkg = JSON.parse(fs.readFileSync(path.join(target_folder, 'package.json')).toString()) - } catch(e) { - Common.errMod(`${process.cwd()} module does not contain any package.json`) - process.exit(1) + var pkg = JSON.parse( + fs.readFileSync(path.join(target_folder, "package.json")).toString() + ); + } catch (e) { + Common.errMod(`${process.cwd()} module does not contain any package.json`); + process.exit(1); } - if (!pkg.name) throw new Error('Attribute name should be present') - if (!pkg.version) throw new Error('Attribute version should be present') - if (!pkg.pm2 && !pkg.apps) throw new Error('Attribute apps should be present') + if (!pkg.name) throw new Error("Attribute name should be present"); + if (!pkg.version) throw new Error("Attribute version should be present"); + if (!pkg.pm2 && !pkg.apps) + throw new Error("Attribute apps should be present"); - var current_path = target_folder - var module_name = path.basename(current_path) - var target_path = os.tmpdir() + var current_path = target_folder; + var module_name = path.basename(current_path); + var target_path = os.tmpdir(); - Common.logMod(`Starting publishing procedure for ${module_name}@${pkg.version}`) + Common.logMod( + `Starting publishing procedure for ${module_name}@${pkg.version}` + ); packager(current_path, target_path, (err, res) => { if (err) { - Common.errMod('Can\'t package, exiting') - process.exit(1) + Common.errMod("Can't package, exiting"); + process.exit(1); } - Common.logMod(`Package [${pkg.name}] created in path ${res.path}`) + Common.logMod(`Package [${pkg.name}] created in path ${res.path}`); var data = { module_data: { file: res.path, - content_type: 'content/gzip' + content_type: "content/gzip", }, id: pkg.name, name: pkg.name, - version: pkg.version + version: pkg.version, }; - var uri = `${PM2.pm2_configuration.registry}/api/v1/modules` - Common.logMod(`Sending Package to remote ${pkg.name} ${uri}`) + var uri = `${PM2.pm2_configuration.registry}/api/v1/modules`; + Common.logMod(`Sending Package to remote ${pkg.name} ${uri}`); - require('needle') - .post(uri, data, { multipart: true }, function(err, res, body) { + require("needle").post( + uri, + data, + { multipart: true }, + function (err, res, body) { if (err) { - Common.errMod(err) - process.exit(1) + Common.errMod(err); + process.exit(1); } if (res.statusCode !== 200) { - Common.errMod(`${pkg.name}-${pkg.version}: ${res.body.msg}`) - process.exit(1) + Common.errMod(`${pkg.name}-${pkg.version}: ${res.body.msg}`); + process.exit(1); } - Common.logMod(`Module ${module_name} published under version ${pkg.version}`) - process.exit(0) - }) - }) + Common.logMod( + `Module ${module_name} published under version ${pkg.version}` + ); + process.exit(0); + } + ); + }); } function needPrefix(conf) { - if ((conf.apps && conf.apps.length > 1) || - (conf.pm2 && conf.pm2.length > 1) || - (conf.apps.length == 1 && conf.name != conf.apps[0].name)) - return true - return false + if ( + (conf.apps && conf.apps.length > 1) || + (conf.pm2 && conf.pm2.length > 1) || + (conf.apps.length == 1 && conf.name != conf.apps[0].name) + ) + return true; + return false; }