gruntfile.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. var sauceConfig = require('./grunt/sauce')
  2. module.exports = function (grunt) {
  3. grunt.initConfig({
  4. version: grunt.file.readJSON('package.json').version,
  5. jshint: {
  6. options: {
  7. reporter: require('jshint-stylish'),
  8. jshintrc: true
  9. },
  10. build: {
  11. src: ['gruntfile.js', 'tasks/*.js']
  12. },
  13. src: {
  14. src: 'src/**/*.js'
  15. },
  16. test: {
  17. src: ['test/unit/specs/**/*.js', 'test/e2e/*.js']
  18. }
  19. },
  20. watch: {
  21. options: {
  22. nospawn: true
  23. },
  24. dev: {
  25. files: ['src/**/*.js'],
  26. tasks: ['dev']
  27. },
  28. test: {
  29. files: ['test/unit/specs/**/*.js'],
  30. tasks: ['build-test']
  31. }
  32. },
  33. karma: {
  34. options: {
  35. frameworks: ['jasmine', 'commonjs'],
  36. files: [
  37. 'src/**/*.js',
  38. 'test/unit/lib/indoc_patch.js',
  39. 'test/unit/specs/**/*.js'
  40. ],
  41. preprocessors: {
  42. 'src/**/*.js': ['commonjs'],
  43. 'test/unit/lib/indoc_patch.js': ['commonjs'],
  44. 'test/unit/specs/**/*.js': ['commonjs']
  45. },
  46. singleRun: true
  47. },
  48. browsers: {
  49. options: {
  50. browsers: ['Chrome', 'Firefox', 'Safari'],
  51. reporters: ['progress']
  52. }
  53. },
  54. coverage: {
  55. options: {
  56. browsers: ['PhantomJS'],
  57. reporters: ['progress', 'coverage'],
  58. preprocessors: {
  59. 'src/**/*.js': ['commonjs', 'coverage'],
  60. 'test/unit/lib/indoc_patch.js': ['commonjs'],
  61. 'test/unit/specs/**/*.js': ['commonjs']
  62. },
  63. coverageReporter: {
  64. reporters: [
  65. { type: 'lcov' },
  66. { type: 'text-summary' }
  67. ]
  68. }
  69. }
  70. },
  71. sauce1: {
  72. options: sauceConfig.batch1
  73. },
  74. sauce2: {
  75. options: sauceConfig.batch2
  76. },
  77. sauce3: {
  78. options: sauceConfig.batch3
  79. }
  80. },
  81. coveralls: {
  82. options: {
  83. coverage_dir: 'coverage/',
  84. force: true
  85. }
  86. }
  87. })
  88. // load npm tasks
  89. grunt.loadNpmTasks('grunt-contrib-jshint')
  90. grunt.loadNpmTasks('grunt-contrib-watch')
  91. grunt.loadNpmTasks('grunt-karma')
  92. grunt.loadNpmTasks('grunt-karma-coveralls')
  93. // load custom tasks
  94. grunt.file.recurse('grunt/tasks', function (path) {
  95. require('./' + path)(grunt)
  96. })
  97. grunt.registerTask('unit', ['karma:browsers'])
  98. grunt.registerTask('cover', ['karma:coverage'])
  99. grunt.registerTask('test', ['unit', 'cover', 'casper'])
  100. grunt.registerTask('sauce', ['karma:sauce1', 'karma:sauce2', 'karma:sauce3'])
  101. grunt.registerTask('ci', ['jshint', 'cover', 'coveralls', 'build', 'casper', 'sauce'])
  102. grunt.registerTask('default', ['jshint', 'build', 'test'])
  103. }