glob.js 854 B

1234567891011121314151617181920212223242526272829
  1. var test = require('tap').test;
  2. var spawn = require('child_process').spawn;
  3. var path = require('path');
  4. var concat = require('concat-stream');
  5. var vm = require('vm');
  6. test('glob', function (t) {
  7. var expected = [ 'a', '!x', 'z', 'b', '!y' ];
  8. t.plan(expected.length + 1);
  9. var cwd = process.cwd();
  10. process.chdir(__dirname);
  11. var ps = spawn(process.execPath, [
  12. path.resolve(__dirname, '../bin/cmd.js'),
  13. 'a.js', 'b.js',
  14. '-u', 'vendor/*.js'
  15. ], { cwd: __dirname + '/glob' });
  16. ps.stderr.pipe(process.stderr);
  17. ps.stdout.pipe(concat(function (body) {
  18. var c = { console: { log: log } };
  19. vm.runInNewContext(body.toString('utf8'), c);
  20. function log (msg) { t.equal(msg, expected.shift()) }
  21. }));
  22. ps.on('exit', function (code) {
  23. t.equal(code, 0);
  24. });
  25. });