log.js 510 B

12345678910111213141516171819202122232425
  1. var exit = require('../../lib/exit');
  2. var errorCode = process.argv[2];
  3. var max = process.argv[3];
  4. var modes = process.argv.slice(4);
  5. function stdout(message) {
  6. if (modes.indexOf('stdout') === -1) { return; }
  7. process.stdout.write('stdout ' + message + '\n');
  8. }
  9. function stderr(message) {
  10. if (modes.indexOf('stderr') === -1) { return; }
  11. process.stderr.write('stderr ' + message + '\n');
  12. }
  13. for (var i = 0; i < max; i++) {
  14. stdout(i);
  15. stderr(i);
  16. }
  17. exit(errorCode);
  18. stdout('fail');
  19. stderr('fail');