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. '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. grunt.registerTask('no-only-tests', function() {
  30. var files = grunt.file.expand(
  31. 'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
  32. 'packages/grafana-ui/**/*@(_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. };