3 module.exports = function ( grunt ) {
5 var wgServer = process.env.MW_SERVER,
6 wgScriptPath = process.env.MW_SCRIPT_PATH,
9 grunt.loadNpmTasks( 'grunt-banana-checker' );
10 grunt.loadNpmTasks( 'grunt-contrib-copy' );
11 grunt.loadNpmTasks( 'grunt-contrib-watch' );
12 grunt.loadNpmTasks( 'grunt-eslint' );
13 grunt.loadNpmTasks( 'grunt-jsonlint' );
14 grunt.loadNpmTasks( 'grunt-karma' );
15 grunt.loadNpmTasks( 'grunt-stylelint' );
17 karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
27 '!resources/src/jquery.tipsy/**',
28 '!resources/src/jquery/jquery.farbtastic.js',
29 '!resources/src/mediawiki.libs/**',
31 // Explicitly say "**/*.js" here in case of symlinks
32 '!extensions/**/*.js',
34 // Skip functions aren't even parseable
35 '!resources/src/dom-level2-skip.js',
36 '!resources/src/es5-skip.js',
37 '!resources/src/mediawiki.hidpi-skip.js'
43 '!{docs/js,extensions,node_modules,skins,vendor}/**'
48 disallowBlankTranslations: false
50 core: 'languages/i18n/',
51 api: 'includes/api/i18n/',
52 installer: 'includes/installer/i18n/'
58 src: '{resources/src/*,mw-config/**}/*.{css,less}'
62 '.{stylelintrc,eslintrc.json}',
64 '!{docs,extensions,node_modules,skins,vendor}/**'
72 pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
78 frameworks: [ 'qunit' ],
79 reporters: [ 'progress' ],
82 // Some tests in extensions don't yield for more than the default 10s (T89075)
83 browserNoActivityTimeout: 60 * 1000
86 browsers: [ 'Chrome' ]
89 browsers: [ 'Chrome', 'Firefox' ]
94 src: 'resources/**/*',
95 dest: 'docs/js/modules',
97 rename: function ( dest, src ) {
98 return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
104 grunt.registerTask( 'assert-mw-env', function () {
105 if ( !process.env.MW_SERVER ) {
106 grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
107 'Set this like $wgServer, e.g. "http://localhost"'
110 if ( !process.env.MW_SCRIPT_PATH ) {
111 grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
112 'Set this like $wgScriptPath, e.g. "/w"' );
114 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
117 grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] );
118 grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
120 grunt.registerTask( 'test', [ 'lint' ] );
121 grunt.registerTask( 'default', 'test' );