Gruntfile.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. module.exports = function (grunt) {
  2. require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. coffee: {
  6. lib: {
  7. options: { bare: false },
  8. files: {
  9. 'morris.js': ['build/morris.coffee']
  10. }
  11. },
  12. spec: {
  13. options: { bare: true },
  14. files: {
  15. 'build/spec.js': ['build/spec.coffee']
  16. }
  17. },
  18. },
  19. concat: {
  20. 'build/morris.coffee': {
  21. options: {
  22. banner: "### @license\n"+
  23. "<%= pkg.name %> v<%= pkg.version %>\n"+
  24. "Copyright <%= (new Date()).getFullYear() %> <%= pkg.author.name %> All rights reserved.\n" +
  25. "Licensed under the <%= pkg.license %> License.\n" +
  26. "###\n",
  27. },
  28. src: [
  29. 'lib/morris.coffee',
  30. 'lib/morris.grid.coffee',
  31. 'lib/morris.hover.coffee',
  32. 'lib/morris.line.coffee',
  33. 'lib/morris.area.coffee',
  34. 'lib/morris.bar.coffee',
  35. 'lib/morris.donut.coffee'
  36. ],
  37. dest: 'build/morris.coffee'
  38. },
  39. 'build/spec.coffee': ['spec/support/**/*.coffee', 'spec/lib/**/*.coffee']
  40. },
  41. less: {
  42. all: {
  43. src: 'less/*.less',
  44. dest: 'morris.css',
  45. options: {
  46. compress: true
  47. }
  48. }
  49. },
  50. uglify: {
  51. build: {
  52. options: {
  53. preserveComments: 'some'
  54. },
  55. files: {
  56. 'morris.min.js': 'morris.js'
  57. }
  58. }
  59. },
  60. mocha: {
  61. index: ['spec/specs.html'],
  62. options: {run: true}
  63. },
  64. watch: {
  65. all: {
  66. files: ['lib/**/*.coffee', 'spec/lib/**/*.coffee', 'spec/support/**/*.coffee', 'less/**/*.less'],
  67. tasks: 'default'
  68. },
  69. dev: {
  70. files: 'lib/*.coffee' ,
  71. tasks: ['concat:build/morris.coffee', 'coffee:lib']
  72. }
  73. },
  74. shell: {
  75. visual_spec: {
  76. command: './run.sh',
  77. options: {
  78. stdout: true,
  79. failOnError: true,
  80. execOptions: {
  81. cwd: 'spec/viz'
  82. }
  83. }
  84. }
  85. }
  86. });
  87. grunt.registerTask('default', ['concat', 'coffee', 'less', 'uglify', 'mocha', 'shell:visual_spec']);
  88. };