Gruntfile.js 3.9 KB

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