process
A cheatsheet by @rstacruz|Refreshed 7 months ago.Refresh|View source on Github

Streams

Streams

process.stdout.write('...');
process.stderr.write('...');

function stdin(fn) {
  var data = '';

  process.stdin.setEncoding('utf8');
  process.stdin.on('readable', function() {
    var chunk = process.stdin.read();
    if (chunk !== null) data += chunk;
  });

  process.stdin.on('end', function() {
    fn(null, data);
  });
}

stuff

stuff

process.argv; //=> ['node', 'file.js', 'one', 'two']
process.env; //=> {TERM: 'screen-256color', SHELL: '/bin/bash', ...}

process.exit();
process.exit(1);

Directories

Directories

process.cwd(); //=> "/tmp"
process.chdir('dir');

References

References

  • http://nodejs.org/api/process.html
This cheat sheet can be found in the following categories: