mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
4986576cc4
Move post-qunit task to qunit.done event which fires both on
success and failure.
Define pre-qunit + qunit as a group test 'unit', so they can
be run from the command line (previously 'grunt qunit' would
fail) as 'grunt unit'.
Also add override comment to css file using non-standard
property so csslint passes again (follows-up b2fbe35
).
Bug: 49431
Change-Id: I5079d00a63d43276a12dd78c306bb3819470631d
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/*!
|
|
* Grunt file
|
|
*
|
|
* @package VisualEditor
|
|
*/
|
|
|
|
/*jshint node:true */
|
|
module.exports = function ( grunt ) {
|
|
var fs = require( 'fs' ),
|
|
exec = require( 'child_process' ).exec;
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
|
|
|
grunt.initConfig( {
|
|
pkg: grunt.file.readJSON( 'package.json' ),
|
|
jshint: {
|
|
options: JSON.parse( grunt.file.read( '.jshintrc' )
|
|
.replace( /\/\*(?:(?!\*\/)[\s\S])*\*\//g, '' ).replace( /\/\/[^\n\r]*/g, '' ) ),
|
|
all: ['*.js', 'modules/**/*.js']
|
|
},
|
|
csslint: {
|
|
options: {
|
|
csslintrc: '.csslintrc'
|
|
},
|
|
all: ['modules/ve/**/*.css']
|
|
},
|
|
qunit: {
|
|
all: ['modules/ve/test/index-phantomjs-tmp.html']
|
|
},
|
|
watch: {
|
|
files: ['<%= jshint.all %>', '<%= csslint.all %>', '<%= qunit.all %>', '.{jshintrc,jshintignore,csslintrc}'],
|
|
tasks: ['test']
|
|
}
|
|
} );
|
|
|
|
grunt.registerTask( 'pre-qunit', function () {
|
|
var done = this.async();
|
|
grunt.file.setBase( __dirname + '/modules/ve/test' );
|
|
exec( 'php index.php > index-phantomjs-tmp.html', function ( err, stdout, stderr ) {
|
|
if ( err || stderr ) {
|
|
grunt.log.error( err || stderr );
|
|
done( false );
|
|
} else {
|
|
grunt.file.setBase( __dirname );
|
|
done( true );
|
|
}
|
|
} );
|
|
} );
|
|
|
|
grunt.event.on( 'qunit.done', function () {
|
|
fs.unlinkSync( __dirname + '/modules/ve/test/index-phantomjs-tmp.html' );
|
|
} );
|
|
|
|
grunt.registerTask( 'lint', ['jshint', 'csslint'] );
|
|
grunt.registerTask( 'unit', ['pre-qunit', 'qunit'] );
|
|
grunt.registerTask( 'test', ['lint', 'unit'] );
|
|
grunt.registerTask( 'default', 'test' );
|
|
};
|