Gruntfile.coffee 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. "use strict"
  2. module.exports = (grunt) ->
  3. # load all grunt tasks
  4. require("matchdep").filterDev("grunt-*").forEach grunt.loadNpmTasks
  5. grunt.initConfig
  6. # load package.json
  7. pkg: grunt.file.readJSON "package.json"
  8. coffeelint:
  9. options:
  10. arrow_spacing:
  11. level: "error"
  12. no_empty_param_list:
  13. level: "error"
  14. no_unnecessary_fat_arrows:
  15. level: "error"
  16. space_operators:
  17. level: "error"
  18. indentation:
  19. value: 2
  20. level: "error"
  21. max_line_length:
  22. level: "ignore"
  23. build: ["Gruntfile.coffee", "src/**/*.coffee"]
  24. coffee:
  25. default:
  26. expand: true
  27. cwd: "src/coffee"
  28. src: "**/*.coffee"
  29. dest: "build/js"
  30. ext: ".js"
  31. test:
  32. expand: true
  33. cwd: "src/test"
  34. src: "**/*.coffee"
  35. dest: "test/"
  36. ext: ".js"
  37. uglify:
  38. build:
  39. expand: true
  40. src: "build/js/bootstrap-switch.js"
  41. ext: ".min.js"
  42. less:
  43. build:
  44. files:
  45. "build/css/bootstrap2/bootstrap-switch.css": "src/less/bootstrap2/build.less"
  46. "build/css/bootstrap3/bootstrap-switch.css": "src/less/bootstrap3/build.less"
  47. cssmin:
  48. build:
  49. expand: true
  50. src: ["build/css/bootstrap2/bootstrap-switch.css", "build/css/bootstrap3/bootstrap-switch.css"]
  51. ext: ".min.css"
  52. usebanner:
  53. options:
  54. banner: "/* ========================================================================\n" +
  55. " * <%= pkg.name %> - v<%= pkg.version %>\n" +
  56. " * <%= pkg.homepage %>\n" +
  57. " * ========================================================================\n" +
  58. " * Copyright 2012-2013 <%= pkg.author.name %>\n" +
  59. " *\n" +
  60. " * ========================================================================\n" +
  61. " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
  62. " * you may not use this file except in compliance with the License.\n" +
  63. " * You may obtain a copy of the License at\n" +
  64. " *\n" +
  65. " * http://www.apache.org/licenses/LICENSE-2.0\n" +
  66. " *\n" +
  67. " * Unless required by applicable law or agreed to in writing, software\n" +
  68. " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
  69. " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
  70. " * See the License for the specific language governing permissions and\n" +
  71. " * limitations under the License.\n" +
  72. " * ========================================================================\n" +
  73. " */\n"
  74. css:
  75. files:
  76. src: ["build/**/*.css"]
  77. js:
  78. files:
  79. src: ["build/**/*.js"]
  80. jshint:
  81. all: ["*.json"]
  82. clean:
  83. css: "build/css"
  84. js: "build/js"
  85. test: "test"
  86. connect:
  87. go:
  88. options:
  89. port: 3000
  90. open:
  91. go:
  92. path: "http://localhost:<%= connect.go.options.port %>"
  93. bump:
  94. options:
  95. files: ["package.json", "bower.json"]
  96. commitFiles: ["-a"]
  97. push: false
  98. jasmine:
  99. options:
  100. keepRunner: true
  101. specs: "test/**/*.js"
  102. vendor: ["docs/vendor/jquery.min.js", "docs/vendor/bootstrap.min.js"]
  103. src: "build/js/bootstrap-switch.js"
  104. watch:
  105. coffee:
  106. files: ["src/**/*.coffee"]
  107. tasks: ["clean:js", "coffeelint", "coffee", "uglify", "usebanner:js"]
  108. less:
  109. files: ["src/**/*.less"],
  110. tasks: ["clean:css", "less", "cssmin", "usebanner:css"]
  111. grunt.registerTask "go", ["build", "connect", "open", "watch"]
  112. grunt.registerTask "build", ["clean", "coffeelint", "coffee", "uglify", "less", "cssmin", "usebanner"]
  113. grunt.registerTask "test", ["build", "jasmine"]