Gruntfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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);\n'
  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. endline: {
  49. dist: {
  50. files: {
  51. 'dist/<%= pkg.name %>.js': 'dist/<%= pkg.name %>.js',
  52. 'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.min.js'
  53. }
  54. }
  55. },
  56. jshint: {
  57. options: {
  58. jshintrc: '.jshintrc',
  59. reporterOutput: ''
  60. },
  61. files: [
  62. 'Gruntfile.js',
  63. 'src/**/*.js',
  64. 'test/**/*.js'
  65. ]
  66. },
  67. jscs: {
  68. options: {
  69. config: '.jscs.json'
  70. },
  71. files: {
  72. src: [
  73. 'Gruntfile.js',
  74. 'src/**/*.js',
  75. 'test/**/*.js'
  76. ]
  77. }
  78. },
  79. conventionalChangelog: {
  80. options: {
  81. changelogOpts: {
  82. preset: 'angular'
  83. }
  84. },
  85. release: {
  86. src: 'CHANGELOG.md'
  87. }
  88. },
  89. conventionalGithubReleaser: {
  90. release: {
  91. options: {
  92. auth: {
  93. type: 'oauth',
  94. token: process.env.GH_TOEKN
  95. },
  96. changelogOpts: {
  97. preset: 'angular'
  98. }
  99. }
  100. }
  101. },
  102. simplemocha: {
  103. node: {
  104. src: 'test/node/**/*.js',
  105. options: {
  106. globals: ['should'],
  107. timeout: 3000,
  108. ignoreLeaks: true,
  109. reporter: 'spec'
  110. }
  111. },
  112. karlcow: {
  113. src: 'test/node/testsuite.karlcow.js',
  114. options: {
  115. globals: ['should'],
  116. timeout: 3000,
  117. ignoreLeaks: false,
  118. reporter: 'spec'
  119. }
  120. },
  121. issues: {
  122. src: 'test/node/testsuite.issues.js',
  123. options: {
  124. globals: ['should'],
  125. timeout: 3000,
  126. ignoreLeaks: false,
  127. reporter: 'spec'
  128. }
  129. },
  130. standard: {
  131. src: 'test/node/testsuite.standard.js',
  132. options: {
  133. globals: ['should'],
  134. timeout: 3000,
  135. ignoreLeaks: false,
  136. reporter: 'spec'
  137. }
  138. },
  139. features: {
  140. src: 'test/node/testsuite.features.js',
  141. options: {
  142. globals: ['should'],
  143. timeout: 3000,
  144. ignoreLeaks: false,
  145. reporter: 'spec'
  146. }
  147. },
  148. single: {
  149. src: 'test/node/**/*.js',
  150. options: {
  151. globals: ['should'],
  152. timeout: 3000,
  153. ignoreLeaks: false,
  154. reporter: 'spec'
  155. }
  156. }
  157. }
  158. };
  159. grunt.initConfig(config);
  160. require('load-grunt-tasks')(grunt);
  161. grunt.registerTask('single-test', function (grep) {
  162. 'use strict';
  163. grunt.config.merge({
  164. simplemocha: {
  165. single: {
  166. options: {
  167. grep: grep
  168. }
  169. }
  170. }
  171. });
  172. grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
  173. });
  174. grunt.registerTask('lint', ['jshint', 'jscs']);
  175. grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
  176. grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
  177. grunt.registerTask('prep-release', ['build', 'conventionalChangelog']);
  178. // Default task(s).
  179. grunt.registerTask('default', ['test']);
  180. };