Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * Created by Tivie on 12-11-2014.
  3. */
  4. module.exports = function (grunt) {
  5. if (grunt.option('q') || grunt.option('quiet')) {
  6. require('quiet-grunt');
  7. }
  8. // Project configuration.
  9. var config = {
  10. pkg: grunt.file.readJSON('package.json'),
  11. concat: {
  12. options: {
  13. sourceMap: true,
  14. banner: ';/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
  15. footer: '}).call(this);'
  16. },
  17. dist: {
  18. src: [
  19. 'src/options.js',
  20. 'src/showdown.js',
  21. 'src/helpers.js',
  22. 'src/converter.js',
  23. 'src/subParsers/*.js',
  24. 'src/loader.js'
  25. ],
  26. dest: 'dist/<%= pkg.name %>.js'
  27. },
  28. test: {
  29. src: '<%= concat.dist.src %>',
  30. dest: '.build/<%= pkg.name %>.js',
  31. options: {
  32. sourceMap: false
  33. }
  34. }
  35. },
  36. clean: ['.build/'],
  37. uglify: {
  38. options: {
  39. sourceMap: true,
  40. banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
  41. },
  42. dist: {
  43. files: {
  44. 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
  45. }
  46. }
  47. },
  48. jshint: {
  49. options: {
  50. jshintrc: '.jshintrc'
  51. },
  52. files: [
  53. 'Gruntfile.js',
  54. 'src/**/*.js',
  55. 'test/**/*.js'
  56. ]
  57. },
  58. jscs: {
  59. options: {
  60. config: '.jscs.json'
  61. },
  62. files: {
  63. src: [
  64. 'Gruntfile.js',
  65. 'src/**/*.js',
  66. 'test/**/*.js'
  67. ]
  68. }
  69. },
  70. changelog: {
  71. options: {
  72. repository: 'http://github.com/showdownjs/showdown',
  73. dest: 'CHANGELOG.md'
  74. }
  75. },
  76. simplemocha: {
  77. node: {
  78. src: 'test/node/**/*.js',
  79. options: {
  80. globals: ['should'],
  81. timeout: 3000,
  82. ignoreLeaks: true,
  83. reporter: 'spec'
  84. }
  85. },
  86. karlcow: {
  87. src: 'test/node/testsuite.karlcow.js',
  88. options: {
  89. globals: ['should'],
  90. timeout: 3000,
  91. ignoreLeaks: false,
  92. reporter: 'spec'
  93. }
  94. },
  95. issues: {
  96. src: 'test/node/testsuite.issues.js',
  97. options: {
  98. globals: ['should'],
  99. timeout: 3000,
  100. ignoreLeaks: false,
  101. reporter: 'spec'
  102. }
  103. },
  104. standard: {
  105. src: 'test/node/testsuite.standard.js',
  106. options: {
  107. globals: ['should'],
  108. timeout: 3000,
  109. ignoreLeaks: false,
  110. reporter: 'spec'
  111. }
  112. },
  113. features: {
  114. src: 'test/node/testsuite.features.js',
  115. options: {
  116. globals: ['should'],
  117. timeout: 3000,
  118. ignoreLeaks: false,
  119. reporter: 'spec'
  120. }
  121. },
  122. single: {
  123. src: 'test/node/**/*.js',
  124. options: {
  125. globals: ['should'],
  126. timeout: 3000,
  127. ignoreLeaks: false,
  128. reporter: 'spec'
  129. }
  130. }
  131. }
  132. };
  133. grunt.initConfig(config);
  134. require('load-grunt-tasks')(grunt);
  135. grunt.registerTask('single-test', function (grep) {
  136. 'use strict';
  137. grunt.config.merge({
  138. simplemocha: {
  139. single: {
  140. options: {
  141. grep: grep
  142. }
  143. }
  144. }
  145. });
  146. grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
  147. });
  148. grunt.registerTask('lint', ['jshint', 'jscs']);
  149. grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
  150. grunt.registerTask('build', ['test', 'concat:dist', 'uglify']);
  151. grunt.registerTask('prep-release', ['build', 'changelog']);
  152. // Default task(s).
  153. grunt.registerTask('default', ['test']);
  154. };