grafana/scripts/grunt/default_task.js
David Kaltschmidt e8a895d58b JS tooling: run TS grunt tasks only when files changed
- using grunt-newer to prefix precommit tasks
- only got it to work for tslint and tsc

Not applied to:

- sasslint does not take the file arguments in a way that grunt-newer
  recognizes
- no-only-tests throws an error when used with `newer`, but it's
  sub-second runtime
2018-10-30 10:25:53 +01:00

39 lines
849 B
JavaScript

// Lint and build CSS
module.exports = function (grunt) {
'use strict';
grunt.registerTask('default', [
'clean:build',
'phantomjs',
'webpack:dev',
]);
grunt.registerTask('test', [
'sasslint',
'exec:tslint',
"exec:jest",
'no-only-tests'
]);
grunt.registerTask('precommit', [
'sasslint',
'newer:exec:tslint',
'newer:exec:tsc',
'no-only-tests'
]);
grunt.registerTask('no-only-tests', function () {
var files = grunt.file.expand('public/**/*_specs\.ts', 'public/**/*_specs\.js');
files.forEach(function (spec) {
var rows = grunt.file.read(spec).split('\n');
rows.forEach(function (row) {
if (row.indexOf('.only(') > 0) {
grunt.log.errorlns(row);
grunt.fail.warn('found only statement in test: ' + spec)
}
});
});
});
};