Skip to content

Commit a7469da

Browse files
committed
squash! remove envPlus, use Object.assign everywhere
1 parent ead0c22 commit a7469da

25 files changed

+43
-44
lines changed

test/common/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ Platform normalizes the `dd` command
5050

5151
Check if there is more than 1gb of total memory.
5252

53-
### envPlus(additionalEnv)
54-
* return [<Object>]
55-
56-
Returns `process.env` plus `additionalEnv`. Used to pass a temporarily modified
57-
environment to a child process.
58-
5953
### expectsError([fn, ]settings[, exact])
6054
* `fn` [<Function>] a function that should throw.
6155
* `settings` [<Object>]

test/common/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ if (exports.isLinux) {
182182
];
183183
}
184184

185-
exports.envPlus = function(additionalEnv) {
186-
return Object.assign({}, process.env, additionalEnv);
187-
};
188-
189185
Object.defineProperty(exports, 'inFreeBSDJail', {
190186
get: function() {
191187
if (inFreeBSDJail !== null) return inFreeBSDJail;

test/parallel/test-benchmark-crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const argv = ['--set', 'algo=sha256',
2727
'--set', 'writes=1',
2828
'crypto'];
2929

30-
const child = fork(runjs, argv, { env: common.envPlus({
30+
const child = fork(runjs, argv, { env: Object.assign({}, process.env, {
3131
NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }) });
3232

3333
child.on('exit', (code, signal) => {

test/parallel/test-benchmark-timers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const common = require('../common');
3+
require('../common');
44

55
// Minimal test for timers benchmarks. This makes sure the benchmarks aren't
66
// horribly broken but nothing more than that.
@@ -15,9 +15,10 @@ const argv = ['--set', 'type=depth',
1515
'--set', 'thousands=0.001',
1616
'timers'];
1717

18-
const child = fork(runjs, argv, { env: common.envPlus({
19-
NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }) });
18+
const env = Object.assign({}, process.env,
19+
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
2020

21+
const child = fork(runjs, argv, { env });
2122
child.on('exit', (code, signal) => {
2223
assert.strictEqual(code, 0);
2324
assert.strictEqual(signal, null);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ Object.setPrototypeOf(env, {
3434

3535
let child;
3636
if (common.isWindows) {
37-
child = spawn('cmd.exe', ['/c', 'set'], common.envPlus({ env: env }));
37+
child = spawn('cmd.exe', ['/c', 'set'],
38+
Object.assign({}, process.env, { env: env }));
3839
} else {
39-
child = spawn('/usr/bin/env', [], common.envPlus({ env: env }));
40+
child = spawn('/usr/bin/env', [],
41+
Object.assign({}, process.env, { env: env }));
4042
}
4143

4244

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ function after(err, stdout, stderr) {
4444
if (!common.isWindows) {
4545
child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after);
4646
} else {
47-
child = exec('set', { env: common.envPlus({ 'HELLO': 'WORLD' }) }, after);
47+
child = exec('set',
48+
{ env: Object.assign({}, process.env, { 'HELLO': 'WORLD' }) },
49+
after);
4850
}
4951

5052
child.stdout.setEncoding('utf8');

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
const env = cp.spawn(`"${process.execPath}" -pe process.env.BAZ`, {
53-
env: common.envPlus({ BAZ: 'buzz' }),
53+
env: Object.assign({}, process.env, { BAZ: 'buzz' }),
5454
encoding: 'utf8',
5555
shell: true
5656
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
2424
const assert = require('assert');
2525
const cp = require('child_process');
2626

@@ -29,7 +29,7 @@ if (process.argv[2] === 'child') {
2929
} else {
3030
const expected = 'bar';
3131
const child = cp.spawnSync(process.execPath, [__filename, 'child'], {
32-
env: common.envPlus({ foo: expected })
32+
env: Object.assign(process.env, { foo: expected })
3333
});
3434

3535
assert.strictEqual(child.stdout.toString().trim(), expected);

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
const env = cp.spawnSync(`"${process.execPath}" -pe process.env.BAZ`, {
40-
env: common.envPlus({ BAZ: 'buzz' }),
40+
env: Object.assign({}, process.env, { BAZ: 'buzz' }),
4141
shell: true
4242
});
4343

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ disallow('--');
2929
disallow('--no_warnings'); // Node options don't allow '_' instead of '-'.
3030

3131
function disallow(opt) {
32-
const options = { env: common.envPlus({ NODE_OPTIONS: opt }) };
32+
const options = { env: Object.assign({}, process.env,
33+
{ NODE_OPTIONS: opt }) };
3334
exec(process.execPath, options, common.mustCall(function(err) {
3435
const message = err.message.split(/\r?\n/)[1];
3536
const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
@@ -71,7 +72,7 @@ function expect(opt, want) {
7172
const printB = require.resolve('../fixtures/printB.js');
7273
const argv = [printB];
7374
const opts = {
74-
env: common.envPlus({ NODE_OPTIONS: opt }),
75+
env: Object.assign({}, process.env, { NODE_OPTIONS: opt }),
7576
maxBuffer: 1000000000,
7677
};
7778
exec(process.execPath, argv, opts, common.mustCall(function(err, stdout) {

0 commit comments

Comments
 (0)