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