default_task.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Lint and build CSS
  2. module.exports = function(grunt) {
  3. 'use strict';
  4. // prettier-ignore
  5. grunt.registerTask('default', [
  6. 'clean:build',
  7. 'phantomjs',
  8. 'webpack:dev'
  9. ]);
  10. // prettier-ignore
  11. grunt.registerTask('test', [
  12. 'sasslint',
  13. 'tslint',
  14. 'typecheck',
  15. 'exec:jest',
  16. 'no-only-tests',
  17. 'no-focus-convey-tests'
  18. ]);
  19. // prettier-ignore
  20. grunt.registerTask('tslint', [
  21. 'newer:exec:tslintPackages',
  22. 'newer:exec:tslintRoot'
  23. ]);
  24. // prettier-ignore
  25. grunt.registerTask('typecheck', [
  26. 'newer:exec:typecheckPackages',
  27. 'newer:exec:typecheckRoot'
  28. ]);
  29. // prettier-ignore
  30. grunt.registerTask('precommit', [
  31. 'newer:sasslint',
  32. 'typecheck',
  33. 'tslint',
  34. 'no-only-tests',
  35. 'no-focus-convey-tests'
  36. ]);
  37. grunt.registerTask('no-only-tests', function() {
  38. var files = grunt.file.expand(
  39. 'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
  40. 'packages/grafana-ui/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
  41. );
  42. grepFiles(files, '.only(', 'found only statement in test: ');
  43. });
  44. grunt.registerTask('no-focus-convey-tests', function() {
  45. var files = grunt.file.expand('pkg/**/*_test.go');
  46. grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: ');
  47. });
  48. function grepFiles(files, pattern, errorMessage) {
  49. files.forEach(function(spec) {
  50. var rows = grunt.file.read(spec).split('\n');
  51. rows.forEach(function(row) {
  52. if (row.indexOf(pattern) > 0) {
  53. grunt.log.errorlns(row);
  54. grunt.fail.warn(errorMessage + spec);
  55. }
  56. });
  57. });
  58. }
  59. };