Gruntfile.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. module.exports = function(grunt) {
  2. var cfg = require('./package.json');
  3. grunt.initConfig({
  4. jshint: {
  5. options: {
  6. trailing: true
  7. },
  8. target: {
  9. src : [
  10. 'converse.js',
  11. 'mock.js',
  12. 'main.js',
  13. 'tests_main.js',
  14. 'spec/*.js'
  15. ]
  16. }
  17. },
  18. cssmin: {
  19. options: {
  20. banner: "/*"+
  21. "* Converse.js (Web-based XMPP instant messaging client) \n"+
  22. "* http://conversejs.org \n"+
  23. "* Copyright (c) 2012, Jan-Carel Brand <jc@opkode.com> \n"+
  24. "* Dual licensed under the MIT and GPL Licenses \n"+
  25. "*/"
  26. },
  27. minify: {
  28. dest: 'converse.min.css',
  29. src: ['converse.css']
  30. }
  31. }
  32. });
  33. grunt.loadNpmTasks('grunt-contrib-cssmin');
  34. grunt.loadNpmTasks('grunt-contrib-jshint');
  35. grunt.loadNpmTasks('grunt-contrib-requirejs');
  36. grunt.registerTask('test', 'Run Tests', function () {
  37. var done = this.async();
  38. var child_process = require('child_process');
  39. var exec = child_process.exec;
  40. exec('./node_modules/.bin/phantomjs '+
  41. 'node_modules/jasmine-reporters/test/phantomjs-testrunner.js '+
  42. __dirname+'/tests.html',
  43. function (err, stdout, stderr) {
  44. if (err) {
  45. grunt.log.write('Tests failed with error code '+err.code);
  46. grunt.log.write(stderr);
  47. }
  48. grunt.log.write(stdout);
  49. done();
  50. });
  51. });
  52. grunt.registerTask('fetch', 'Set up the development environment', function () {
  53. var done = this.async();
  54. var child_process = require('child_process');
  55. var exec = child_process.exec;
  56. exec('./node_modules/.bin/bower update',
  57. function (err, stdout, stderr) {
  58. if (err) {
  59. grunt.log.write('build failed with error code '+err.code);
  60. grunt.log.write(stderr);
  61. }
  62. grunt.log.write(stdout);
  63. done();
  64. });
  65. });
  66. grunt.registerTask('jsmin', 'Create a new release', function () {
  67. var done = this.async();
  68. var child_process = require('child_process');
  69. var exec = child_process.exec;
  70. var callback = function (err, stdout, stderr) {
  71. if (err) {
  72. grunt.log.write('build failed with error code '+err.code);
  73. grunt.log.write(stderr);
  74. }
  75. grunt.log.write(stdout);
  76. done();
  77. };
  78. exec('./node_modules/requirejs/bin/r.js -o src/build.js && ' +
  79. './node_modules/requirejs/bin/r.js -o src/build-no-locales-no-otr.js && ' +
  80. './node_modules/requirejs/bin/r.js -o src/build-no-otr.js', callback);
  81. });
  82. grunt.registerTask('minify', 'Create a new release', ['cssmin', 'jsmin']);
  83. grunt.registerTask('check', 'Perform all checks (e.g. before releasing)', function () {
  84. grunt.task.run('jshint', 'test');
  85. });
  86. };