2 module.exports = function ( grunt ) {
3 grunt.loadNpmTasks( 'grunt-contrib-copy' );
4 grunt.loadNpmTasks( 'grunt-contrib-jshint' );
5 grunt.loadNpmTasks( 'grunt-contrib-watch' );
6 grunt.loadNpmTasks( 'grunt-banana-checker' );
7 grunt.loadNpmTasks( 'grunt-jscs' );
8 grunt.loadNpmTasks( 'grunt-jsonlint' );
9 grunt.loadNpmTasks( 'grunt-karma' );
11 var wgServer = process.env.MW_SERVER,
12 wgScriptPath = process.env.MW_SCRIPT_PATH,
15 karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
31 '!{docs/js,extensions,node_modules,skins,vendor}/**'
36 disallowBlankTranslations: false
38 core: 'languages/i18n/',
39 api: 'includes/api/i18n/',
40 installer: 'includes/installer/i18n/'
46 '!{docs,extensions,node_modules,skins,vendor}/**'
54 pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
59 frameworks: [ 'qunit' ],
60 reporters: [ 'dots' ],
63 // Some tests in extensions don't yield for more than the default 10s (T89075)
64 browserNoActivityTimeout: 60 * 1000
67 browsers: [ 'Chrome' ]
70 browsers: [ 'Chrome', 'Firefox' ]
75 src: 'resources/**/*',
76 dest: 'docs/js/modules',
78 rename: function ( dest, src ) {
79 return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
85 grunt.registerTask( 'assert-mw-env', function () {
86 if ( !process.env.MW_SERVER ) {
87 grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
88 'Set this like $wgServer, e.g. "http://localhost"'
91 if ( !process.env.MW_SCRIPT_PATH ) {
92 grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
93 'Set this like $wgScriptPath, e.g. "/w"' );
95 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
98 grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] );
99 grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
101 grunt.registerTask( 'test', [ 'lint' ] );
102 grunt.registerTask( 'default', 'test' );