gruntfile.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2015 The MemDB Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. // implied. See the License for the specific language governing
  13. // permissions and limitations under the License. See the AUTHORS file
  14. // for names of contributors.
  15. 'use strict';
  16. module.exports = function(grunt) {
  17. // Unified Watch Object
  18. var watchFiles = {
  19. libJS: ['gruntfile.js', 'index.js', 'app/**/*.js', 'bin/**/*.js', 'lib/**/*.js'],
  20. testJS: ['test/app/*.js', 'test/bin/*.js', 'test/lib/*.js', 'test/perf.js'],
  21. };
  22. // Project Configuration
  23. grunt.initConfig({
  24. pkg: grunt.file.readJSON('package.json'),
  25. env: {
  26. test: {
  27. NODE_ENV: 'test'
  28. }
  29. },
  30. watch: {
  31. libJS: {
  32. files: watchFiles.libJS.concat(watchFiles.testJS),
  33. tasks: ['jshint'],
  34. options: {
  35. livereload: true
  36. }
  37. }
  38. },
  39. jshint: {
  40. all: {
  41. src: watchFiles.libJS.concat(watchFiles.testJS),
  42. options: {
  43. jshintrc: true
  44. }
  45. }
  46. },
  47. mochaTest: {
  48. test : {
  49. src: watchFiles.testJS,
  50. options : {
  51. reporter: 'spec',
  52. timeout: 10000,
  53. require: 'test/blanket'
  54. }
  55. },
  56. // coverage: {
  57. // src: watchFiles.testJS,
  58. // options : {
  59. // reporter: 'html-cov',
  60. // quiet: true,
  61. // captureFile: 'coverage.html'
  62. // }
  63. // }
  64. },
  65. clean: {
  66. 'coverage.html' : {
  67. src: ['coverage.html']
  68. }
  69. },
  70. nodemon: {
  71. dev: {
  72. script: 'bin/memdbd',
  73. options: {
  74. args : ['--conf=./test/memdb.conf.js', '--shard=s1'],
  75. nodeArgs: ['--debug'],
  76. ext: 'js,html',
  77. watch: watchFiles.serverJS
  78. }
  79. }
  80. },
  81. 'node-inspector': {
  82. custom: {
  83. options: {
  84. 'web-port': 8088,
  85. 'web-host': 'localhost',
  86. 'debug-port': 5858,
  87. 'save-live-edit': true,
  88. 'no-preload': true,
  89. 'stack-trace-limit': 50,
  90. 'hidden': []
  91. }
  92. }
  93. },
  94. concurrent: {
  95. default: ['nodemon', 'watch'],
  96. debug: ['nodemon', 'watch', 'node-inspector'],
  97. options: {
  98. logConcurrentOutput: true,
  99. limit: 10
  100. }
  101. },
  102. });
  103. // Load NPM tasks
  104. require('load-grunt-tasks')(grunt);
  105. // Making grunt default to force in order not to break the project.
  106. grunt.option('force', true);
  107. // Lint task(s).
  108. grunt.registerTask('lint', ['jshint']);
  109. // Test task.
  110. grunt.registerTask('test', ['clean', 'lint', 'env:test', 'mochaTest']);
  111. // Run server
  112. grunt.registerTask('default', ['clean', 'lint', 'concurrent:default']);
  113. // Debug server
  114. grunt.registerTask('debug', ['clean', 'lint', 'concurrent:debug']);
  115. };