gruntfile.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2015 rain1017.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. // implied. See the License for the specific language governing
  13. // permissions and limitations under the License. See the AUTHORS file
  14. // for names of contributors.
  15. 'use strict';
  16. module.exports = function(grunt) {
  17. // Unified Watch Object
  18. var watchFiles = {
  19. libJS: ['gruntfile.js', 'index.js', 'lib/**/*.js'],
  20. testJS: ['test/**/*.js'],
  21. };
  22. // Project Configuration
  23. grunt.initConfig({
  24. pkg: grunt.file.readJSON('package.json'),
  25. watch: {
  26. libJS: {
  27. files: watchFiles.libJS,
  28. tasks: ['jshint'],
  29. options: {
  30. livereload: true
  31. }
  32. }
  33. },
  34. jshint: {
  35. all: {
  36. src: watchFiles.libJS.concat(watchFiles.testJS),
  37. options: {
  38. jshintrc: true
  39. }
  40. }
  41. },
  42. env: {
  43. test: {
  44. NODE_ENV: 'test'
  45. }
  46. },
  47. mochaTest: {
  48. test : {
  49. src: watchFiles.testJS,
  50. options : {
  51. reporter: 'spec',
  52. timeout: 5 * 1000,
  53. require: 'test/blanket'
  54. }
  55. },
  56. coverage: {
  57. src: watchFiles.testJS,
  58. options : {
  59. reporter: 'html-cov',
  60. quiet: true,
  61. captureFile: 'coverage.html'
  62. }
  63. }
  64. },
  65. clean: {
  66. 'coverage.html' : {
  67. src: ['coverage.html']
  68. }
  69. }
  70. });
  71. // Load NPM tasks
  72. require('load-grunt-tasks')(grunt);
  73. // Making grunt default to force in order not to break the project.
  74. grunt.option('force', true);
  75. // Lint task(s).
  76. grunt.registerTask('lint', ['jshint']);
  77. // Test task.
  78. grunt.registerTask('test', ['clean', 'env:test', 'lint', 'mochaTest']);
  79. // Default task(s).
  80. grunt.registerTask('default', ['test']);
  81. };