You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
6.1 KiB

  1. module.exports = function (grunt) {
  2. 'use strict';
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. uglify : {
  6. target: {
  7. files: {
  8. 'build/js/bootstrap-datetimepicker.min.js' : 'src/js/bootstrap-datetimepicker.js'
  9. }
  10. },
  11. options: {
  12. mangle: true,
  13. compress: {
  14. dead_code: false // jshint ignore:line
  15. },
  16. output: {
  17. ascii_only: true // jshint ignore:line
  18. },
  19. report: 'min',
  20. preserveComments: 'some'
  21. }
  22. },
  23. jshint: {
  24. all: [
  25. 'Gruntfile.js', 'src/js/*.js', 'test/*.js'
  26. ],
  27. options: {
  28. 'browser' : true,
  29. 'node' : true,
  30. 'jquery' : true,
  31. 'boss' : false,
  32. 'curly' : true,
  33. 'debug' : false,
  34. 'devel' : false,
  35. 'eqeqeq' : true,
  36. 'bitwise' : true,
  37. 'eqnull' : true,
  38. 'evil' : false,
  39. 'forin' : true,
  40. 'immed' : false,
  41. 'laxbreak' : false,
  42. 'newcap' : true,
  43. 'noarg' : true,
  44. 'noempty' : false,
  45. 'nonew' : false,
  46. 'onevar' : true,
  47. 'plusplus' : false,
  48. 'regexp' : false,
  49. 'undef' : true,
  50. 'sub' : true,
  51. 'strict' : true,
  52. 'unused' : true,
  53. 'white' : true,
  54. 'es3' : true,
  55. 'camelcase' : true,
  56. 'quotmark' : 'single',
  57. 'globals': {
  58. 'define': false,
  59. 'moment': false,
  60. // Jasmine
  61. 'jasmine': false,
  62. 'describe': false,
  63. 'xdescribe': false,
  64. 'expect': false,
  65. 'it': false,
  66. 'xit': false,
  67. 'spyOn': false,
  68. 'beforeEach': false,
  69. 'afterEach': false
  70. }
  71. }
  72. },
  73. jscs: {
  74. all: [
  75. 'Gruntfile.js', 'src/js/*.js', 'test/*.js'
  76. ],
  77. options: {
  78. config: '.jscs.json'
  79. }
  80. },
  81. less: {
  82. production: {
  83. options: {
  84. cleancss: true
  85. },
  86. files: {
  87. 'build/css/bootstrap-datetimepicker.min.css': 'src/less/bootstrap-datetimepicker-build.less'
  88. }
  89. },
  90. development: {
  91. files: {
  92. 'build/css/bootstrap-datetimepicker.css': 'src/less/bootstrap-datetimepicker-build.less'
  93. }
  94. }
  95. },
  96. jasmine: {
  97. customTemplate: {
  98. src: 'src/js/*.js',
  99. options: {
  100. specs: 'test/*Spec.js',
  101. helpers: 'test/*Helper.js',
  102. styles: [
  103. 'node_modules/bootstrap/dist/css/bootstrap.min.css',
  104. 'build/css/bootstrap-datetimepicker.min.css'
  105. ],
  106. vendor: [
  107. 'node_modules/jquery/dist/jquery.min.js',
  108. 'node_modules/moment/min/moment-with-locales.min.js',
  109. 'node_modules/bootstrap/dist/js/bootstrap.min.js'
  110. ],
  111. display: 'none',
  112. summary: 'true'
  113. }
  114. }
  115. }
  116. });
  117. grunt.loadTasks('tasks');
  118. grunt.loadNpmTasks('grunt-contrib-jasmine');
  119. // These plugins provide necessary tasks.
  120. require('load-grunt-tasks')(grunt);
  121. // Default task.
  122. grunt.registerTask('default', ['jshint', 'jscs', 'less', 'jasmine']);
  123. // travis build task
  124. grunt.registerTask('build:travis', [
  125. // code style
  126. 'jshint', 'jscs',
  127. // build
  128. 'uglify', 'less',
  129. // tests
  130. 'jasmine'
  131. ]);
  132. // Task to be run when building
  133. grunt.registerTask('build', [
  134. 'jshint', 'jscs', 'uglify', 'less'
  135. ]);
  136. grunt.registerTask('nuget', 'Create a nuget package', function () {
  137. var target = grunt.option('target') || 'less', done = this.async();
  138. if (target === 'less') {
  139. grunt.util.spawn({
  140. cmd: 'src/nuget/nuget.exe',
  141. args: [
  142. 'pack',
  143. 'src/nuget/Bootstrap.v3.Datetimepicker.nuspec',
  144. '-OutputDirectory',
  145. 'build/nuget',
  146. '-Version',
  147. grunt.config.get('pkg').version
  148. ]
  149. }, function (error, result) {
  150. if (error) {
  151. grunt.log.error(error);
  152. } else {
  153. grunt.log.write(result);
  154. }
  155. done();
  156. });
  157. }
  158. else { //--target=css
  159. grunt.util.spawn({
  160. cmd: 'src/nuget/nuget.exe',
  161. args: [
  162. 'pack',
  163. 'src/nuget/Bootstrap.v3.Datetimepicker.CSS.nuspec',
  164. '-OutputDirectory',
  165. 'build/nuget',
  166. '-Version',
  167. grunt.config.get('pkg').version
  168. ]
  169. }, function (error, result) {
  170. if (error) {
  171. grunt.log.error(error);
  172. } else {
  173. grunt.log.write(result);
  174. }
  175. done();
  176. });
  177. }
  178. });
  179. grunt.registerTask('test', ['jshint', 'jscs', 'uglify', 'less', 'jasmine']);
  180. };