grafana/scripts/grunt/default_task.js

58 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-11-14 17:07:14 -06:00
// Lint and build CSS
module.exports = function(grunt) {
2015-09-10 04:26:40 -05:00
'use strict';
// prettier-ignore
2015-09-10 04:26:40 -05:00
grunt.registerTask('default', [
'clean:build',
]);
// prettier-ignore
grunt.registerTask('test', [
'sasslint',
'eslint',
2018-12-21 07:37:38 -06:00
'typecheck',
'exec:jest',
'no-only-tests',
'no-focus-convey-tests'
2015-09-10 04:26:40 -05:00
]);
// prettier-ignore
grunt.registerTask('eslint', [
'newer:exec:eslintPackages',
'newer:exec:eslintRoot'
]);
// prettier-ignore
grunt.registerTask('typecheck', [
'newer:exec:typecheckPackages',
'newer:exec:typecheckRoot'
]);
grunt.registerTask('no-only-tests', function() {
2019-03-18 04:39:14 -05:00
var files = grunt.file.expand(
'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
'packages/grafana-data/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
'packages/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
2019-03-18 04:39:14 -05:00
);
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: ');
});
function grepFiles(files, pattern, errorMessage) {
files.forEach(function(spec) {
var rows = grunt.file.read(spec).split('\n');
rows.forEach(function(row) {
if (row.indexOf(pattern) > 0) {
grunt.log.errorlns(row);
grunt.fail.warn(errorMessage + spec);
}
});
});
}
2014-05-31 00:46:39 -05:00
};