Gruntfile.js 4.1 KB

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