gruntfile.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. module.exports = function(grunt) {
  2. var pkg = grunt.file.readJSON('package.json');
  3. var banner = [
  4. '/**',
  5. '* Ajax Autocomplete for jQuery, version ' + pkg.version,
  6. '* (c) 2014 Tomas Kirda',
  7. '*',
  8. '* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.',
  9. '* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete',
  10. '*/'].join('\n') + '\n';
  11. // Project configuration.
  12. grunt.initConfig({
  13. pkg: pkg,
  14. uglify: {
  15. options: {
  16. banner: banner
  17. },
  18. build: {
  19. src: 'src/jquery.autocomplete.js',
  20. dest: 'dist/jquery.autocomplete.min.js'
  21. }
  22. }
  23. });
  24. // Load the plugin that provides the "uglify" task.
  25. grunt.loadNpmTasks('grunt-contrib-uglify');
  26. // Default task(s).
  27. grunt.registerTask('default', ['uglify']);
  28. grunt.task.registerTask('build', 'Create release', function() {
  29. var version = pkg.version,
  30. src = grunt.file.read('src/jquery.autocomplete.js').replace('%version%', version),
  31. filePath = 'dist/jquery.autocomplete.js';
  32. // Update not minimized release version:
  33. console.log('Updating: ' + filePath);
  34. grunt.file.write(filePath, src);
  35. // Minify latest version:
  36. grunt.task.run('uglify');
  37. // Update plugin version:
  38. filePath = 'devbridge-autocomplete.jquery.json';
  39. src = grunt.file.readJSON(filePath);
  40. if (src.version !== version){
  41. src.version = version;
  42. console.log('Updating: ' + filePath);
  43. grunt.file.write(filePath, JSON.stringify(src, null, 4));
  44. } else {
  45. console.log('No updates for: ' + filePath);
  46. }
  47. // Update bower version:
  48. filePath = 'bower.json';
  49. src = grunt.file.readJSON(filePath);
  50. if (src.version !== version){
  51. src.version = version;
  52. console.log('Updating: ' + filePath);
  53. grunt.file.write(filePath, JSON.stringify(src, null, 4));
  54. } else {
  55. console.log('No updates for: ' + filePath);
  56. }
  57. });
  58. };