bin_entry.js 800 B

12345678910111213141516171819202122232425262728293031
  1. var test = require('tap').test;
  2. var spawn = require('child_process').spawn;
  3. var path = require('path');
  4. var vm = require('vm');
  5. test('bin --entry', function (t) {
  6. t.plan(3);
  7. var cwd = process.cwd();
  8. process.chdir(__dirname);
  9. var ps = spawn(process.execPath, [
  10. path.resolve(__dirname, '../bin/cmd.js'),
  11. '--entry', 'entry/main.js'
  12. ]);
  13. var src = '';
  14. var err = '';
  15. ps.stdout.on('data', function (buf) { src += buf });
  16. ps.stderr.on('data', function (buf) { err += buf });
  17. ps.on('exit', function (code) {
  18. t.equal(code, 0);
  19. t.equal(err, '');
  20. var allDone = false;
  21. var c = { done : function () { allDone = true } };
  22. vm.runInNewContext(src, c);
  23. t.ok(allDone);
  24. });
  25. });