Skip to content

Commit bd6a29c

Browse files
franherBridgeAR
authored andcommitted
test: use spread object
Object.assign() can be replaced by spread objects PR-URL: #30423 Refs: https://eslint.org/docs/rules/prefer-object-spread Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent d3a8088 commit bd6a29c

23 files changed

Lines changed: 31 additions & 31 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const{ spawnSync }=require('child_process');
2-
constenv=Object.assign({},process.env,{NODE_V8_COVERAGE: ''});
2+
constenv={ ...process.env,NODE_V8_COVERAGE: ''};
33
spawnSync(process.execPath,[require.resolve('./subprocess')],{
44
env: env
55
});

‎test/fixtures/v8-coverage/spawn-subprocess.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const{ spawnSync }=require('child_process');
2-
constenv=Object.assign({},process.env);
2+
constenv={ ...process.env};
33
deleteenv.NODE_V8_COVERAGE
44
spawnSync(process.execPath,[require.resolve('./subprocess')],{
55
env: env

‎test/parallel/test-child-process-env.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ const os = require('os');
2626

2727
constspawn=require('child_process').spawn;
2828

29-
constenv=Object.assign({},process.env,{
29+
constenv={
30+
...process.env,
3031
'HELLO': 'WORLD',
3132
'UNDEFINED': undefined,
3233
'NULL': null,
3334
'EMPTY': ''
34-
});
35+
};
3536
Object.setPrototypeOf(env,{
3637
'FOO': 'BAR'
3738
});

‎test/parallel/test-child-process-exec-env.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (!common.isWindows) {
4545
child=exec('/usr/bin/env',{env: {'HELLO': 'WORLD'}},after);
4646
}else{
4747
child=exec('set',
48-
{env: Object.assign({},process.env,{'HELLO': 'WORLD'})},
48+
{env: { ...process.env,'HELLO': 'WORLD'}},
4949
after);
5050
}
5151

‎test/parallel/test-child-process-fork-no-shell.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const expected = common.isWindows ? '%foo%' : '$foo';
88
if(process.argv[2]===undefined){
99
constchild=cp.fork(__filename,[expected],{
1010
shell: true,
11-
env: Object.assign({},process.env,{foo: 'bar'})
11+
env: { ...process.env,foo: 'bar'}
1212
});
1313

1414
child.on('exit',common.mustCall((code,signal)=>{

‎test/parallel/test-child-process-spawn-shell.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ command.on('close', common.mustCall((code, signal) => {
5050

5151
// Verify that the environment is properly inherited
5252
constenv=cp.spawn(`"${process.execPath}" -pe process.env.BAZ`,{
53-
env: Object.assign({},process.env,{BAZ: 'buzz'}),
53+
env: { ...process.env,BAZ: 'buzz'},
5454
encoding: 'utf8',
5555
shell: true
5656
});

‎test/parallel/test-child-process-spawnsync-shell.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ assert.strictEqual(command.stdout.toString().trim(), 'bar');
3737

3838
// Verify that the environment is properly inherited
3939
constenv=cp.spawnSync(`"${process.execPath}" -pe process.env.BAZ`,{
40-
env: Object.assign({},process.env,{BAZ: 'buzz'}),
40+
env: { ...process.env,BAZ: 'buzz'},
4141
shell: true
4242
});
4343

‎test/parallel/test-cli-node-options-disallowed.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ disallow('--v8-options');
2828
disallow('--');
2929

3030
functiondisallow(opt){
31-
constenv=Object.assign({},process.env,{NODE_OPTIONS: opt});
31+
constenv={ ...process.env,NODE_OPTIONS: opt};
3232
exec(process.execPath,{cwd: tmpdir.path, env },common.mustCall((err)=>{
3333
constmessage=err.message.split(/\r?\n/)[1];
3434
constexpect=`${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;

‎test/parallel/test-crypto-fips.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ testHelper(
7171
[],
7272
FIPS_DISABLED,
7373
'require("crypto").getFips()',
74-
Object.assign({},process.env,{'OPENSSL_CONF': ''}));
74+
{ ...process.env,'OPENSSL_CONF': ''});
7575

7676
// --enable-fips should turn FIPS mode on
7777
testHelper(

‎test/parallel/test-env-var-no-warnings.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (process.argv[2] === 'child') {
77
process.emitWarning('foo');
88
}else{
99
functiontest(newEnv){
10-
constenv=Object.assign({},process.env,newEnv);
10+
constenv={ ...process.env,...newEnv};
1111
constcmd=`"${process.execPath}" "${__filename}" child`;
1212

1313
cp.exec(cmd,{ env },common.mustCall((err,stdout,stderr)=>{

0 commit comments

Comments
 (0)