default_task.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. ]);
  9. // prettier-ignore
  10. grunt.registerTask('test', [
  11. 'sasslint',
  12. 'tslint',
  13. 'typecheck',
  14. 'exec:jest',
  15. 'no-only-tests',
  16. 'no-focus-convey-tests'
  17. ]);
  18. // prettier-ignore
  19. grunt.registerTask('tslint', [
  20. 'newer:exec:tslintPackages',
  21. 'newer:exec:tslintRoot'
  22. ]);
  23. // prettier-ignore
  24. grunt.registerTask('typecheck', [
  25. 'newer:exec:typecheckPackages',
  26. 'newer:exec:typecheckRoot'
  27. ]);
  28. grunt.registerTask('no-only-tests', function() {
  29. var files = grunt.file.expand(
  30. 'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
  31. 'packages/grafana-data/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
  32. 'packages/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
  33. );
  34. grepFiles(files, '.only(', 'found only statement in test: ');
  35. });
  36. grunt.registerTask('no-focus-convey-tests', function() {
  37. var files = grunt.file.expand('pkg/**/*_test.go');
  38. grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: ');
  39. });
  40. function grepFiles(files, pattern, errorMessage) {
  41. files.forEach(function(spec) {
  42. var rows = grunt.file.read(spec).split('\n');
  43. rows.forEach(function(row) {
  44. if (row.indexOf(pattern) > 0) {
  45. grunt.log.errorlns(row);
  46. grunt.fail.warn(errorMessage + spec);
  47. }
  48. });
  49. });
  50. }
  51. };