spawn-command-test.js 737 B

123456789101112131415161718192021222324252627
  1. var path = require('path'),
  2. assert = require('assert'),
  3. assertCalled = require('assert-called'),
  4. spawnCommand = require('../');
  5. var win32 = (process.platform === 'win32'),
  6. newln = win32 ? '\r\n' : '\n',
  7. grep = win32 ? 'findstr' : 'grep',
  8. child = spawnCommand(grep + ' commit < ' + path.join(__dirname, 'fixtures', 'commit')),
  9. stderr = '',
  10. stdout = '',
  11. exited = false;
  12. child.stdout.on('data', function (chunk) {
  13. stdout += chunk;
  14. });
  15. child.stderr.on('data', function (chunk) {
  16. stderr += chunk;
  17. });
  18. child.on('exit', assertCalled(function (exitCode) {
  19. assert.equal(exitCode, 0);
  20. assert.equal(stdout, 'commit 26b11915b1c16440468a4b5f4b07d2409b98c68c' + newln);
  21. assert.equal(stderr, '');
  22. }));