Skip to content

Instantly share code, notes, and snippets.

@g-k
Created March 13, 2017 22:06
Show Gist options
  • Save g-k/233f531fcbdee50887d55a8a750584af to your computer and use it in GitHub Desktop.
Save g-k/233f531fcbdee50887d55a8a750584af to your computer and use it in GitHub Desktop.
nested node exec call debugging
» node test.js
outer call $PATH:
/Users/gguthe/.cargo/bin:/Developer/NVIDIA/CUDA-5.0/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/lib:/usr/local/lib/python2.7/site-packages:/Users/gguthe/bin:/Users/gguthe/.cabal/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gguthe/.cargo/bin:/Developer/NVIDIA/CUDA-5.0/bin:/usr/local/share/npm/bin:/usr/local/lib:/usr/local/lib/python2.7/site-packages:/Users/gguthe/bin:/Users/gguthe/.cabal/bin:/usr/local/opt/go/libexec/bin:/Users/gguthe/bin/bin:/usr/local/opt/go/libexec/bin:/Users/gguthe/bin/bin
inner call $PATH:
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var cp = require('child_process')
var cmd = 'echo $PATH'
cp.exec(cmd, function(err, stdout) {
var cmd = 'echo $PATH'
console.log('outer call $PATH:\n', stdout)
cp.exec(cmd, { env: { GIT_CONFIG: 'BLAH' } }, function(err, stdout) {
console.log('inner call $PATH:\n', stdout)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment