tr_flags.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var through = require('through2');
  2. var mdeps = require('../');
  3. var test = require('tap').test;
  4. test('--debug passed to transforms', function (t) {
  5. var empty = require.resolve('./tr_flags/empty.js');
  6. t.plan(5);
  7. var p
  8. [true, false].forEach(function(debug) {
  9. p = mdeps({
  10. debug: debug,
  11. transform: function (file, opts) {
  12. t.equal(opts._flags.debug, debug, 'debug: ' + debug);
  13. return through();
  14. }
  15. })
  16. p.on('error', function (err) { return t.fail(err.message) })
  17. p.end(empty);
  18. p = mdeps({ debug: debug })
  19. p.write({
  20. transform: function (file, opts) {
  21. t.equal(opts._flags.debug, debug, 'debug: ' + debug);
  22. return through();
  23. },
  24. options: {}
  25. })
  26. p.on('error', function (err) { return t.fail(err.message) })
  27. p.end(empty);
  28. });
  29. p = mdeps({ debug: true })
  30. p.write({
  31. transform: function (file, opts) {
  32. t.equal(opts._flags, Infinity, 'transform arguments are preserved');
  33. return through();
  34. },
  35. options: { _flags: Infinity }
  36. })
  37. p.on('error', function (err) { return t.fail(err.message) })
  38. p.end(empty);
  39. });