redeyed-shebang.js 609 B

12345678910111213141516171819202122232425
  1. 'use strict'
  2. var test = require('tape')
  3. var util = require('util')
  4. var redeyed = require('..')
  5. function inspect(obj) {
  6. return util.inspect(obj, false, 5, true)
  7. }
  8. test('preserves shebang', function(t) {
  9. var code = [
  10. '#!/usr/bin/env node'
  11. , 'var util = require("util");'
  12. ].join('\n')
  13. var opts = { Keyword: { 'var': '%:^' } }
  14. var expected = [
  15. '#!/usr/bin/env node'
  16. , '%var^ util = require("util");'
  17. ].join('\n')
  18. var res = redeyed(code, opts).code
  19. t.equals(res, expected, inspect(code) + ' opts: ' + inspect(opts) + ' => ' + inspect(expected))
  20. t.end()
  21. })