mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
refactor: replace deprecated util._extend with Object.assign
This commit is contained in:
parent
b902551b87
commit
df7a9be198
@ -109,4 +109,4 @@ var csts = {
|
||||
|
||||
};
|
||||
|
||||
module.exports = util._extend(csts, path_structure);
|
||||
module.exports = Object.assign(csts, path_structure);
|
||||
|
||||
16
lib/API.js
16
lib/API.js
@ -81,7 +81,7 @@ class API {
|
||||
if (opts.pm2_home) {
|
||||
// Override default conf file
|
||||
this.pm2_home = opts.pm2_home;
|
||||
conf = util._extend(conf, path_structure(this.pm2_home));
|
||||
conf = Object.assign(conf, path_structure(this.pm2_home));
|
||||
}
|
||||
else if (opts.independent == true && conf.IS_WINDOWS === false) {
|
||||
// Create an unique pm2 instance
|
||||
@ -93,7 +93,7 @@ class API {
|
||||
// It will go as in proc
|
||||
if (typeof(opts.daemon_mode) == 'undefined')
|
||||
this.daemon_mode = false;
|
||||
conf = util._extend(conf, path_structure(this.pm2_home));
|
||||
conf = Object.assign(conf, path_structure(this.pm2_home));
|
||||
}
|
||||
|
||||
this._conf = conf;
|
||||
@ -876,7 +876,7 @@ class API {
|
||||
resolved_paths.env['PM2_HOME'] = that.pm2_home;
|
||||
|
||||
var additional_env = Modularizer.getAdditionalConf(resolved_paths.name);
|
||||
util._extend(resolved_paths.env, additional_env);
|
||||
Object.assign(resolved_paths.env, additional_env);
|
||||
|
||||
// Is KM linked?
|
||||
resolved_paths.km_link = that.gl_is_km_linked;
|
||||
@ -1072,7 +1072,7 @@ class API {
|
||||
// Notice: if people use the same name in different apps,
|
||||
// duplicated envs will be overrode by the last one
|
||||
var env = envs.reduce(function(e1, e2){
|
||||
return util._extend(e1, e2);
|
||||
return Object.assign(e1, e2);
|
||||
});
|
||||
|
||||
// When we are processing JSON, allow to keep the new env by default
|
||||
@ -1147,7 +1147,7 @@ class API {
|
||||
resolved_paths.env['PM2_HOME'] = that.pm2_home;
|
||||
|
||||
var additional_env = Modularizer.getAdditionalConf(resolved_paths.name);
|
||||
util._extend(resolved_paths.env, additional_env);
|
||||
Object.assign(resolved_paths.env, additional_env);
|
||||
|
||||
resolved_paths.env = Common.mergeEnvironmentVariables(resolved_paths, opts.env, deployConf);
|
||||
|
||||
@ -1368,7 +1368,7 @@ class API {
|
||||
if (conf.PM2_PROGRAMMATIC == true)
|
||||
new_env = Common.safeExtend({}, process.env);
|
||||
else
|
||||
new_env = util._extend({}, process.env);
|
||||
new_env = Object.assign({}, process.env);
|
||||
|
||||
Object.keys(envs).forEach(function(k) {
|
||||
new_env[k] = envs[k];
|
||||
@ -1510,7 +1510,7 @@ class API {
|
||||
* if yes load configuration variables and merge with the current environment
|
||||
*/
|
||||
var additional_env = Modularizer.getAdditionalConf(process_name);
|
||||
util._extend(envs, additional_env);
|
||||
Object.assign(envs, additional_env);
|
||||
return processIds(ids, cb);
|
||||
}
|
||||
|
||||
@ -1529,7 +1529,7 @@ class API {
|
||||
* if yes load configuration variables and merge with the current environment
|
||||
*/
|
||||
var ns_additional_env = Modularizer.getAdditionalConf(process_name);
|
||||
util._extend(envs, ns_additional_env);
|
||||
Object.assign(envs, ns_additional_env);
|
||||
return processIds(ns_process_ids, cb);
|
||||
});
|
||||
});
|
||||
|
||||
@ -257,9 +257,9 @@ Client.prototype.launchDaemon = function(opts, cb) {
|
||||
detached : true,
|
||||
cwd : that.conf.cwd || process.cwd(),
|
||||
windowsHide: true,
|
||||
env : util._extend({
|
||||
'SILENT' : that.conf.DEBUG ? !that.conf.DEBUG : true,
|
||||
'PM2_HOME' : that.pm2_home
|
||||
env : Object.assign({
|
||||
'SILENT' : that.conf.DEBUG ? !that.conf.DEBUG : true,
|
||||
'PM2_HOME' : that.pm2_home
|
||||
}, process.env),
|
||||
stdio : ['ipc', out, err]
|
||||
});
|
||||
|
||||
@ -208,7 +208,7 @@ Common.prepareAppConf = function(opts, app) {
|
||||
app.env = [
|
||||
{}, (app.filter_env && app.filter_env.length > 0) ? filterEnv(process.env) : env, app.env || {}
|
||||
].reduce(function(e1, e2){
|
||||
return util._extend(e1, e2);
|
||||
return Object.assign(e1, e2);
|
||||
});
|
||||
|
||||
app.pm_cwd = cwd;
|
||||
@ -593,19 +593,19 @@ Common.mergeEnvironmentVariables = function(app_env, env_name, deploy_conf) {
|
||||
/**
|
||||
* Extra configuration update
|
||||
*/
|
||||
util._extend(new_conf, app)
|
||||
Object.assign(new_conf, app);
|
||||
|
||||
if (env_name) {
|
||||
// First merge variables from deploy.production.env object as least priority.
|
||||
if (deploy_conf && deploy_conf[env_name] && deploy_conf[env_name]['env']) {
|
||||
util._extend(new_conf.env, deploy_conf[env_name]['env']);
|
||||
Object.assign(new_conf.env, deploy_conf[env_name]['env']);
|
||||
}
|
||||
|
||||
util._extend(new_conf.env, app.env);
|
||||
Object.assign(new_conf.env, app.env);
|
||||
|
||||
// Then, last and highest priority, merge the app.env_production object.
|
||||
if ('env_' + env_name in app) {
|
||||
util._extend(new_conf.env, app['env_' + env_name]);
|
||||
Object.assign(new_conf.env, app['env_' + env_name]);
|
||||
}
|
||||
else {
|
||||
Common.printOut(cst.PREFIX_MSG_WARNING + chalk.bold('Environment [%s] is not defined in process file'), env_name);
|
||||
@ -618,8 +618,8 @@ Common.mergeEnvironmentVariables = function(app_env, env_name, deploy_conf) {
|
||||
current_conf: {}
|
||||
}
|
||||
|
||||
util._extend(res, new_conf.env)
|
||||
util._extend(res.current_conf, new_conf)
|
||||
Object.assign(res, new_conf.env);
|
||||
Object.assign(res.current_conf, new_conf);
|
||||
|
||||
// #2541 force resolution of node interpreter
|
||||
if (app.exec_interpreter &&
|
||||
|
||||
@ -426,7 +426,7 @@ Daemon.prototype.startLogic = function() {
|
||||
if (!msg.process || !God.clusters_db[msg.process.pm_id])
|
||||
return console.error('AXM MONITOR Unknown id %s', msg.process.pm_id);
|
||||
|
||||
util._extend(God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor, Utility.clone(msg.data));
|
||||
Object.assign(God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor, Utility.clone(msg.data));
|
||||
msg = null;
|
||||
});
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ module.exports = function ClusterMode(God) {
|
||||
};
|
||||
|
||||
if (pm2_env.watch_options) {
|
||||
watch_options = util._extend(watch_options, pm2_env.watch_options);
|
||||
watch_options = Object.assign(watch_options, pm2_env.watch_options);
|
||||
}
|
||||
|
||||
log('Watch opts', watch_options);
|
||||
|
||||
@ -81,7 +81,7 @@ Config.filterOptions = function(cmd) {
|
||||
*/
|
||||
Config.validateJSON = function(json){
|
||||
// clone config
|
||||
var conf = util._extend({}, json),
|
||||
var conf = Object.assign({}, json),
|
||||
res = {};
|
||||
this._errors = [];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user