|
|
@@ -1,52 +1,68 @@
|
|
|
// Lint and build CSS
|
|
|
-module.exports = function (grunt) {
|
|
|
+module.exports = function(grunt) {
|
|
|
'use strict';
|
|
|
|
|
|
+ // prettier-ignore
|
|
|
grunt.registerTask('default', [
|
|
|
'clean:build',
|
|
|
'phantomjs',
|
|
|
- 'webpack:dev',
|
|
|
+ 'webpack:dev'
|
|
|
]);
|
|
|
|
|
|
+ // prettier-ignore
|
|
|
grunt.registerTask('test', [
|
|
|
'sasslint',
|
|
|
'tslint',
|
|
|
'typecheck',
|
|
|
- "exec:jest",
|
|
|
- 'no-only-tests'
|
|
|
+ 'exec:jest',
|
|
|
+ 'no-only-tests',
|
|
|
+ 'no-focus-convey-tests'
|
|
|
]);
|
|
|
|
|
|
+ // prettier-ignore
|
|
|
grunt.registerTask('tslint', [
|
|
|
'newer:exec:tslintPackages',
|
|
|
- 'newer:exec:tslintRoot',
|
|
|
+ 'newer:exec:tslintRoot'
|
|
|
]);
|
|
|
|
|
|
+ // prettier-ignore
|
|
|
grunt.registerTask('typecheck', [
|
|
|
'newer:exec:typecheckPackages',
|
|
|
- 'newer:exec:typecheckRoot',
|
|
|
+ 'newer:exec:typecheckRoot'
|
|
|
]);
|
|
|
|
|
|
+ // prettier-ignore
|
|
|
grunt.registerTask('precommit', [
|
|
|
'newer:sasslint',
|
|
|
'typecheck',
|
|
|
'tslint',
|
|
|
- 'no-only-tests'
|
|
|
+ 'no-only-tests',
|
|
|
+ 'no-focus-convey-tests'
|
|
|
]);
|
|
|
|
|
|
- grunt.registerTask('no-only-tests', function () {
|
|
|
+ grunt.registerTask('no-only-tests', function() {
|
|
|
var files = grunt.file.expand(
|
|
|
- 'public/**/*@(_specs|\.test)\.@(ts|js|tsx|jsx)',
|
|
|
- 'packages/grafana-ui/**/*@(_specs|\.test)\.@(ts|js|tsx|jsx)'
|
|
|
+ 'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
|
|
|
+ 'packages/grafana-ui/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
|
|
|
);
|
|
|
+ grepFiles(files, '.only(', 'found only statement in test: ');
|
|
|
+ });
|
|
|
+
|
|
|
+ grunt.registerTask('no-focus-convey-tests', function() {
|
|
|
+ var files = grunt.file.expand('pkg/**/*_test.go');
|
|
|
+ grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: ');
|
|
|
+ });
|
|
|
|
|
|
- files.forEach(function (spec) {
|
|
|
+ function grepFiles(files, pattern, errorMessage) {
|
|
|
+ files.forEach(function(spec) {
|
|
|
var rows = grunt.file.read(spec).split('\n');
|
|
|
- rows.forEach(function (row) {
|
|
|
- if (row.indexOf('.only(') > 0) {
|
|
|
+ rows.forEach(function(row) {
|
|
|
+ if (row.indexOf(pattern) > 0) {
|
|
|
grunt.log.errorlns(row);
|
|
|
- grunt.fail.warn('found only statement in test: ' + spec);
|
|
|
+ grunt.fail.warn(errorMessage + spec);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
};
|
|
|
+
|