Skip to content
Myr

Fix extending from process.env when no env option is provided - fixes #101 (#102)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sam Verschueren · committed by Sindre Sorhus · parent f071546 · Browse files · 2 files+16 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−2 removed

  • other:+16 added−2 removed

2 files+16 added−2 removed

modified:index.js+7 added-2 removed
14 unmodified lines
1516function handleArgs(cmd, args, opts) {17 let parsed;1819 if (opts && opts.env && opts.extendEnv !== false) {19 opts = Object.assign({20 extendEnv: true,21 env: {}22 }, opts);2324 if (opts.extendEnv) {25 opts.env = Object.assign({}, process.env, opts.env);26 }2723 if (opts && opts.__winShell === true) {28 if (opts.__winShell === true) {29 delete opts.__winShell;30 parsed = {31 command: cmd,32 args,
282 unmodified lines
modified:test.js+9 added
429 unmodified lines
430 }431 });432}433434test('use environment variables by default', async t => {435 const result = await m.stdout('environment');436437 t.deepEqual(result.split('\n'), [438 'foo',439 'undefined'440 ]);441});442443test('extend environment variables by default', async t => {444 const result = await m.stdout('environment', [], {env: {BAR: 'bar'}});445446 t.deepEqual(result.split('\n'), [
13 unmodified lines