Bash script / environment settings w/ child_process
<p>We can fork a child_process like so and set some environment variables:</p>

<pre><code> const n = cp.fork(path.resolve(__dirname + '/run-child.js'), [], {
           env: {
                    'NODE_ENV': process.env.NODE_ENV,
                    'HOME': process.env.HOME,
                    'USERPROFILE': process.env.USERPROFILE
          }
  });
</code></pre>

<p>my question is - is there a way to somehow hook in a bash script so that I can add environment settings for this particular <code>child_process</code> to use?</p>

<p>Right now, this is all JavaScript, and there's not an easy way to incorporate bash scripting, and I am just wondering if there is some facility to do that - where the settings would only apply to this particular child_process.</p>

<p>What we could do instead is this:</p>

<pre><code>     const file = 'some-bash-script.sh';

       cp.spawn('sh', [file], {
            env: {
                NODE_ENV: process.env.NODE_ENV
            }
        });
</code></pre>

<p>and the contents of the bash script might be</p>

<p>//some-bash-script.sh</p>

<pre><code>    # manually set date to 23:30 04/06/2016
    date 233004062016;
    node index.js --foo --bar
    # use ntp to reset the date
    ntpdate us.pool.ntp.org
</code></pre>

<p>is that pretty much the way to do it?</p>