Gruntfile.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Created by Tivie on 12-11-2014.
  3. */
  4. module.exports = function (grunt) {
  5. // Project configuration.
  6. var config = {
  7. pkg: grunt.file.readJSON('package.json'),
  8. concat: {
  9. options: {
  10. sourceMap: true,
  11. banner: ';/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
  12. footer: '}).call(this);'
  13. },
  14. dist: {
  15. src: [
  16. 'src/showdown.js',
  17. 'src/helpers.js',
  18. 'src/converter.js',
  19. 'src/subParsers/*.js',
  20. 'src/loader.js'
  21. ],
  22. dest: 'dist/<%= pkg.name %>.js'
  23. },
  24. test: {
  25. src: '<%= concat.dist.dest %>',
  26. dest: '.build/<%= pkg.name %>.js',
  27. options: {
  28. sourceMap: false
  29. }
  30. }
  31. },
  32. clean: ['.build/'],
  33. uglify: {
  34. options: {
  35. sourceMap: true,
  36. banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
  37. },
  38. dist: {
  39. files: {
  40. 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
  41. }
  42. }
  43. },
  44. jshint: {
  45. options: {
  46. jshintrc: '.jshintrc'
  47. },
  48. files: [
  49. 'Gruntfile.js',
  50. 'src/**/*.js',
  51. 'test/**/*.js'
  52. ]
  53. },
  54. jscs: {
  55. options: {
  56. config: '.jscs.json'
  57. },
  58. files: {
  59. src: [
  60. 'Gruntfile.js',
  61. 'src/**/*.js',
  62. 'test/**/*.js'
  63. ]
  64. }
  65. },
  66. changelog: {
  67. options: {
  68. repository: 'http://github.com/showdownjs/showdown',
  69. dest: 'CHANGELOG.md'
  70. }
  71. },
  72. simplemocha: {
  73. node: {
  74. src: 'test/node/**/*.js',
  75. options: {
  76. globals: ['should'],
  77. timeout: 3000,
  78. ignoreLeaks: false,
  79. reporter: 'spec'
  80. }
  81. },
  82. karlcow: {
  83. src: 'test/node/testsuite.karlcow.js',
  84. options: {
  85. globals: ['should'],
  86. timeout: 3000,
  87. ignoreLeaks: false,
  88. reporter: 'spec'
  89. },
  90. issues: {
  91. src: 'test/node/testsuite.issues.js',
  92. options: {
  93. globals: ['should'],
  94. timeout: 3000,
  95. ignoreLeaks: false,
  96. reporter: 'spec'
  97. }
  98. }
  99. }
  100. }
  101. };
  102. grunt.initConfig(config);
  103. require('load-grunt-tasks')(grunt);
  104. grunt.registerTask('concatenate', ['concat:dist']);
  105. grunt.registerTask('lint', ['jshint', 'jscs']);
  106. grunt.registerTask('test', ['lint', 'concat:test', 'simplemocha:node', 'clean']);
  107. grunt.registerTask('build', ['test', 'concatenate', 'uglify']);
  108. grunt.registerTask('prep-release', ['build', 'changelog']);
  109. // Default task(s).
  110. grunt.registerTask('default', ['test']);
  111. };