Skip to content

Commit c1e2e52

Browse files
authored
Merge pull request Unitech#5239 from hyaocuk/refactor/util-extend
refactor: replace deprecated util._extend with Object.assign
2 parents 0dccb41 + df7a9be commit c1e2e52

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ var csts = {
109109

110110
};
111111

112-
module.exports = util._extend(csts, path_structure);
112+
module.exports = Object.assign(csts, path_structure);

lib/API.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class API {
8181
if (opts.pm2_home) {
8282
// Override default conf file
8383
this.pm2_home = opts.pm2_home;
84-
conf = util._extend(conf, path_structure(this.pm2_home));
84+
conf = Object.assign(conf, path_structure(this.pm2_home));
8585
}
8686
else if (opts.independent == true && conf.IS_WINDOWS === false) {
8787
// Create an unique pm2 instance
@@ -93,7 +93,7 @@ class API {
9393
// It will go as in proc
9494
if (typeof(opts.daemon_mode) == 'undefined')
9595
this.daemon_mode = false;
96-
conf = util._extend(conf, path_structure(this.pm2_home));
96+
conf = Object.assign(conf, path_structure(this.pm2_home));
9797
}
9898

9999
this._conf = conf;
@@ -876,7 +876,7 @@ class API {
876876
resolved_paths.env['PM2_HOME'] = that.pm2_home;
877877

878878
var additional_env = Modularizer.getAdditionalConf(resolved_paths.name);
879-
util._extend(resolved_paths.env, additional_env);
879+
Object.assign(resolved_paths.env, additional_env);
880880

881881
// Is KM linked?
882882
resolved_paths.km_link = that.gl_is_km_linked;
@@ -1072,7 +1072,7 @@ class API {
10721072
// Notice: if people use the same name in different apps,
10731073
// duplicated envs will be overrode by the last one
10741074
var env = envs.reduce(function(e1, e2){
1075-
return util._extend(e1, e2);
1075+
return Object.assign(e1, e2);
10761076
});
10771077

10781078
// When we are processing JSON, allow to keep the new env by default
@@ -1147,7 +1147,7 @@ class API {
11471147
resolved_paths.env['PM2_HOME'] = that.pm2_home;
11481148

11491149
var additional_env = Modularizer.getAdditionalConf(resolved_paths.name);
1150-
util._extend(resolved_paths.env, additional_env);
1150+
Object.assign(resolved_paths.env, additional_env);
11511151

11521152
resolved_paths.env = Common.mergeEnvironmentVariables(resolved_paths, opts.env, deployConf);
11531153

@@ -1368,7 +1368,7 @@ class API {
13681368
if (conf.PM2_PROGRAMMATIC == true)
13691369
new_env = Common.safeExtend({}, process.env);
13701370
else
1371-
new_env = util._extend({}, process.env);
1371+
new_env = Object.assign({}, process.env);
13721372

13731373
Object.keys(envs).forEach(function(k) {
13741374
new_env[k] = envs[k];
@@ -1510,7 +1510,7 @@ class API {
15101510
* if yes load configuration variables and merge with the current environment
15111511
*/
15121512
var additional_env = Modularizer.getAdditionalConf(process_name);
1513-
util._extend(envs, additional_env);
1513+
Object.assign(envs, additional_env);
15141514
return processIds(ids, cb);
15151515
}
15161516

@@ -1529,7 +1529,7 @@ class API {
15291529
* if yes load configuration variables and merge with the current environment
15301530
*/
15311531
var ns_additional_env = Modularizer.getAdditionalConf(process_name);
1532-
util._extend(envs, ns_additional_env);
1532+
Object.assign(envs, ns_additional_env);
15331533
return processIds(ns_process_ids, cb);
15341534
});
15351535
});

lib/Client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ Client.prototype.launchDaemon = function(opts, cb) {
257257
detached : true,
258258
cwd : that.conf.cwd || process.cwd(),
259259
windowsHide: true,
260-
env : util._extend({
261-
'SILENT' : that.conf.DEBUG ? !that.conf.DEBUG : true,
262-
'PM2_HOME' : that.pm2_home
260+
env : Object.assign({
261+
'SILENT' : that.conf.DEBUG ? !that.conf.DEBUG : true,
262+
'PM2_HOME' : that.pm2_home
263263
}, process.env),
264264
stdio : ['ipc', out, err]
265265
});

lib/Common.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Common.prepareAppConf = function(opts, app) {
208208
app.env = [
209209
{}, (app.filter_env && app.filter_env.length > 0) ? filterEnv(process.env) : env, app.env || {}
210210
].reduce(function(e1, e2){
211-
return util._extend(e1, e2);
211+
return Object.assign(e1, e2);
212212
});
213213

214214
app.pm_cwd = cwd;
@@ -593,19 +593,19 @@ Common.mergeEnvironmentVariables = function(app_env, env_name, deploy_conf) {
593593
/**
594594
* Extra configuration update
595595
*/
596-
util._extend(new_conf, app)
596+
Object.assign(new_conf, app);
597597

598598
if (env_name) {
599599
// First merge variables from deploy.production.env object as least priority.
600600
if (deploy_conf && deploy_conf[env_name] && deploy_conf[env_name]['env']) {
601-
util._extend(new_conf.env, deploy_conf[env_name]['env']);
601+
Object.assign(new_conf.env, deploy_conf[env_name]['env']);
602602
}
603603

604-
util._extend(new_conf.env, app.env);
604+
Object.assign(new_conf.env, app.env);
605605

606606
// Then, last and highest priority, merge the app.env_production object.
607607
if ('env_' + env_name in app) {
608-
util._extend(new_conf.env, app['env_' + env_name]);
608+
Object.assign(new_conf.env, app['env_' + env_name]);
609609
}
610610
else {
611611
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) {
618618
current_conf: {}
619619
}
620620

621-
util._extend(res, new_conf.env)
622-
util._extend(res.current_conf, new_conf)
621+
Object.assign(res, new_conf.env);
622+
Object.assign(res.current_conf, new_conf);
623623

624624
// #2541 force resolution of node interpreter
625625
if (app.exec_interpreter &&

lib/Daemon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Daemon.prototype.startLogic = function() {
426426
if (!msg.process || !God.clusters_db[msg.process.pm_id])
427427
return console.error('AXM MONITOR Unknown id %s', msg.process.pm_id);
428428

429-
util._extend(God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor, Utility.clone(msg.data));
429+
Object.assign(God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor, Utility.clone(msg.data));
430430
msg = null;
431431
});
432432

lib/Watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = function ClusterMode(God) {
4242
};
4343

4444
if (pm2_env.watch_options) {
45-
watch_options = util._extend(watch_options, pm2_env.watch_options);
45+
watch_options = Object.assign(watch_options, pm2_env.watch_options);
4646
}
4747

4848
log('Watch opts', watch_options);

lib/tools/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Config.filterOptions = function(cmd) {
8181
*/
8282
Config.validateJSON = function(json){
8383
// clone config
84-
var conf = util._extend({}, json),
84+
var conf = Object.assign({}, json),
8585
res = {};
8686
this._errors = [];
8787

0 commit comments

Comments
 (0)