Gruntfile.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. 'meta': {
  4. 'testFile': 'tests/tests.js'
  5. },
  6. 'uglify': {
  7. 'dist': {
  8. 'options': {
  9. 'report': 'gzip',
  10. 'preserveComments': 'some'
  11. },
  12. 'files': {
  13. 'punycode.min.js': ['punycode.js']
  14. }
  15. }
  16. },
  17. // 'esmangle': {
  18. // 'dist': {
  19. // 'options': {
  20. // 'banner': require('fs').readFileSync('punycode.js', 'utf8').split('\n')[0] + '\n;'
  21. // },
  22. // 'files': {
  23. // 'punycode.min.js': ['punycode.js']
  24. // }
  25. // }
  26. // },
  27. 'shell': {
  28. 'options': {
  29. 'stdout': true,
  30. 'stderr': true,
  31. 'failOnError': true
  32. },
  33. 'cover-html': {
  34. 'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"'
  35. },
  36. 'cover-coveralls': {
  37. 'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && cat coverage/lcov.info | coveralls; rm -rf coverage/lcov*'
  38. },
  39. 'test-narwhal': {
  40. 'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"'
  41. },
  42. 'test-phantomjs': {
  43. 'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"'
  44. },
  45. // Rhino 1.7R4 has a bug that makes it impossible to test in.
  46. // https://bugzilla.mozilla.org/show_bug.cgi?id=775566
  47. // To test, use Rhino 1.7R3, or wait (heh) for the 1.7R5 release.
  48. 'test-rhino': {
  49. 'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"',
  50. 'options': {
  51. 'execOptions': {
  52. 'cwd': 'tests'
  53. }
  54. }
  55. },
  56. 'test-ringo': {
  57. 'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"'
  58. },
  59. 'test-node': {
  60. 'command': 'echo "Testing in Node..."; node "tests/tests.js"'
  61. },
  62. 'test-browser': {
  63. 'command': 'echo "Testing in a browser..."; open "tests/index.html"'
  64. }
  65. }
  66. });
  67. grunt.loadNpmTasks('grunt-shell');
  68. grunt.loadNpmTasks('grunt-contrib-uglify');
  69. //grunt.loadNpmTasks('grunt-esmangle');
  70. grunt.registerTask('cover', 'shell:cover-html');
  71. grunt.registerTask('ci', [
  72. 'shell:test-narwhal',
  73. 'shell:test-phantomjs',
  74. 'shell:test-rhino',
  75. 'shell:test-ringo',
  76. 'shell:test-node'
  77. ]);
  78. grunt.registerTask('test', [
  79. 'ci',
  80. 'shell:test-browser'
  81. ]);
  82. grunt.registerTask('default', [
  83. 'uglify',
  84. 'shell:test-node'
  85. ]);
  86. };