Gruntfile.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. };