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