From 88b3abc985a4e05d46b836d4e7f6b8a87f0ad0bf Mon Sep 17 00:00:00 2001 From: Unitech Date: Thu, 27 Sep 2018 17:24:24 +0200 Subject: [PATCH] feature: pm2 internal config --- lib/API.js | 4 +++- test/programmatic/internal_config.mocha.js | 20 ++++++++++++++++++++ test/unit.sh | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/programmatic/internal_config.mocha.js diff --git a/lib/API.js b/lib/API.js index 0b02773a..15ec68e0 100644 --- a/lib/API.js +++ b/lib/API.js @@ -26,7 +26,8 @@ var path_structure = require('../paths.js'); var UX = require('./API/CliUx'); var pkg = require('../package.json'); var flagWatch = require("./API/Modules/flagWatch.js"); -var hf = require('./API/Modules/flagExt.js'); +var hf = require('./API/Modules/flagExt.js'); +var Configuration = require('./Configuration.js'); var IMMUTABLE_MSG = chalk.bold.blue('Use --update-env to update environment variables'); @@ -94,6 +95,7 @@ class API { conf = util._extend(conf, path_structure(this.pm2_home)); } + this.user_conf = Configuration.getSync('pm2') this._conf = conf; if (conf.IS_WINDOWS) { diff --git a/test/programmatic/internal_config.mocha.js b/test/programmatic/internal_config.mocha.js new file mode 100644 index 00000000..90b942c2 --- /dev/null +++ b/test/programmatic/internal_config.mocha.js @@ -0,0 +1,20 @@ + +const PM2 = require('../..'); +const should = require('should'); + +describe('Internal PM2 configuration', function() { + var pm2 + + before(function() { + pm2 = new PM2.custom(); + }) + + it('should set pm2:registry', function(done) { + pm2.set('pm2:registry', 'http://thing.com', done) + }) + + it('should new instance have the configuration', function() { + var pm3 = new PM2.custom(); + should(pm2.user_conf.registry).eql('http://thing.com') + }) +}) diff --git a/test/unit.sh b/test/unit.sh index ea462e26..acc03d51 100644 --- a/test/unit.sh +++ b/test/unit.sh @@ -52,6 +52,8 @@ mocha --exit --opts ./mocha.opts ./version.mocha.js spec "Package json version retriever" mocha --exit --opts ./mocha.opts ./exp_backoff_restart_delay.mocha.js spec "Exponential backoff restart delay tests" +mocha --exit --opts ./mocha.opts ./internal_config.mocha.js +spec "PM2 local configuration working" mocha --exit --opts ./mocha.opts ./api.backward.compatibility.mocha.js spec "API Backward compatibility tests"