Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4022617

Browse filesBrowse files
franhertargos
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 39dbc10 commit 4022617
Copy full SHA for 4022617
Expand file treeCollapse file tree

23 files changed

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

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

Copy file name to clipboardExpand all lines: test/fixtures/v8-coverage/spawn-subprocess.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { spawnSync } = require('child_process');
2-
const env = Object.assign({}, process.env);
2+
const env = { ...process.env };
33
delete env.NODE_V8_COVERAGE
44
spawnSync(process.execPath, [require.resolve('./subprocess')], {
55
env: env
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-env.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ const os = require('os');
2626

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

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

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-exec-env.js
+1-1Lines 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

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-fork-no-shell.js
+1-1Lines 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
const child = 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) => {
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawn-shell.js
+1-1Lines 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
const env = 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
});
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawnsync-shell.js
+1-1Lines 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
const env = 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

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-cli-node-options-disallowed.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ disallow('--v8-options');
2828
disallow('--');
2929

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

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

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-fips.js
+1-1Lines 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(
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-env-var-no-warnings.js
+1-1Lines 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
function test(newEnv) {
10-
const env = Object.assign({}, process.env, newEnv);
10+
const env = { ...process.env, ...newEnv };
1111
const cmd = `"${process.execPath}" "${__filename}" child`;
1212

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.