Gruntfile.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. conventionalChangelog: {
  71. options: {
  72. changelogOpts: {
  73. preset: 'angular'
  74. }
  75. },
  76. release: {
  77. src: 'CHANGELOG.md'
  78. }
  79. },
  80. simplemocha: {
  81. node: {
  82. src: 'test/node/**/*.js',
  83. options: {
  84. globals: ['should'],
  85. timeout: 3000,
  86. ignoreLeaks: true,
  87. reporter: 'spec'
  88. }
  89. },
  90. karlcow: {
  91. src: 'test/node/testsuite.karlcow.js',
  92. options: {
  93. globals: ['should'],
  94. timeout: 3000,
  95. ignoreLeaks: false,
  96. reporter: 'spec'
  97. }
  98. },
  99. issues: {
  100. src: 'test/node/testsuite.issues.js',
  101. options: {
  102. globals: ['should'],
  103. timeout: 3000,
  104. ignoreLeaks: false,
  105. reporter: 'spec'
  106. }
  107. },
  108. standard: {
  109. src: 'test/node/testsuite.standard.js',
  110. options: {
  111. globals: ['should'],
  112. timeout: 3000,
  113. ignoreLeaks: false,
  114. reporter: 'spec'
  115. }
  116. },
  117. features: {
  118. src: 'test/node/testsuite.features.js',
  119. options: {
  120. globals: ['should'],
  121. timeout: 3000,
  122. ignoreLeaks: false,
  123. reporter: 'spec'
  124. }
  125. },
  126. single: {
  127. src: 'test/node/**/*.js',
  128. options: {
  129. globals: ['should'],
  130. timeout: 3000,
  131. ignoreLeaks: false,
  132. reporter: 'spec'
  133. }
  134. }
  135. }
  136. };
  137. grunt.initConfig(config);
  138. require('load-grunt-tasks')(grunt);
  139. grunt.registerTask('single-test', function (grep) {
  140. 'use strict';
  141. grunt.config.merge({
  142. simplemocha: {
  143. single: {
  144. options: {
  145. grep: grep
  146. }
  147. }
  148. }
  149. });
  150. grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
  151. });
  152. grunt.registerTask('lint', ['jshint', 'jscs']);
  153. grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
  154. grunt.registerTask('build', ['test', 'concat:dist', 'uglify']);
  155. grunt.registerTask('prep-release', ['build', 'conventionalChangelog']);
  156. // Default task(s).
  157. grunt.registerTask('default', ['test']);
  158. };