title: How to programmatically detect debug mode in nodejs?
body: <p>I've seen this question asked of other platform/languages - any ideas? I'd like to do something like:</p>
  
  <pre><code>if (detectDebug())
  {
      require('tty').setRawMode(true);    
      var stdin = process.openStdin();
  
      stdin.on('keypress', function (chunk, key) {
          DoWork();
      }
  }
  else
  {
      DoWork();
  }
  </code></pre>
  
  <p>I'd like to be able to toggle keyboard input as a start for the script when debugging so that I can have a moment to fire up chrome to listen to my node-inspector port. </p>
  
  <p>***Quick update - I'm guessing I can actually use "process.argv" to detect if --debug was passed in. Is this the best/right way?</p>