title: How to exec in NodeJS using the user's environment?
body: <p>I am trying to execute a command in Node:</p>
  
  <pre><code>cd "/www/foo/" &amp;&amp; "/path/to/git/bin/git.exe" config --list --global
  </code></pre>
  
  <p>Basically, I want to execute a Git command that returns global configuration (for the current user).</p>
  
  <p>This works fine for me when I  execute the command directly on cli. It also works if I do it like this in Node:</p>
  
  <pre><code>var exec = require('child_process').exec;
  
  var config = {
      maxBuffer: 10000 * 1024
  };
  
  exec('cd "/www/foo/" &amp;&amp; "/path/to/git/bin/git.exe" config --list --global', config, function() {
      console.log(arguments);
  });
  </code></pre>
  
  <p>However, as soon as I specify the environment to the config:</p>
  
  <pre><code>var exec = require('child_process').exec;
  
  var config = {
      maxBuffer: 10000 * 1024,
      env: { // &lt;--- this one
      }
  };
  
  exec('cd "/www/foo/" &amp;&amp; "/path/to/git/bin/git.exe" config --list --global', config, function() {
      console.log(arguments);
  });
  </code></pre>
  
  <p>Things break: </p>
  
  <blockquote>
    <p>Command failed: fatal: unable to read config file
    '(null)/(null)/.gitconfig': No such file or directory</p>
  </blockquote>
  
  <p>I know the reason, it is because the executed Git program is no longer executed under the user environment (like it is in cli), and can't retrieve the user directory to read global configuration (in Git, global config = user config) and I believe <code>/(null)/(null)/.gitconfig</code> should be <code>/Users/MyName/.gitconfig</code> which does exist.</p>
  
  <p>My question is, how can I specify the current user environment while still being able to specify my own additional environment properties?</p>