API: Add isset() to avoid PHP warning
[mediawiki.git] / Gruntfile.js
blob946b6522f42dd0b184029246793e7500be4436c0
1 /*jshint node:true */
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,
13                 karmaProxy = {};
15         karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
17         grunt.initConfig( {
18                 jshint: {
19                         options: {
20                                 jshintrc: true
21                         },
22                         all: '.'
23                 },
24                 jscs: {
25                         all: '.'
26                 },
27                 jsonlint: {
28                         all: [
29                                 '.jscsrc',
30                                 '**/*.json',
31                                 '!{docs/js,extensions,node_modules,skins,vendor}/**'
32                         ]
33                 },
34                 banana: {
35                         options: {
36                                 disallowBlankTranslations: false
37                         },
38                         core: 'languages/i18n/',
39                         api: 'includes/api/i18n/',
40                         installer: 'includes/installer/i18n/'
41                 },
42                 watch: {
43                         files: [
44                                 '.js*',
45                                 '**/*',
46                                 '!{docs,extensions,node_modules,skins,vendor}/**'
47                         ],
48                         tasks: 'test'
49                 },
50                 karma: {
51                         options: {
52                                 proxies: karmaProxy,
53                                 files: [ {
54                                         pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
55                                         watched: false,
56                                         included: true,
57                                         served: false
58                                 } ],
59                                 frameworks: [ 'qunit' ],
60                                 reporters: [ 'dots' ],
61                                 singleRun: true,
62                                 autoWatch: false,
63                                 // Some tests in extensions don't yield for more than the default 10s (T89075)
64                                 browserNoActivityTimeout: 60 * 1000
65                         },
66                         main: {
67                                 browsers: [ 'Chrome' ]
68                         },
69                         more: {
70                                 browsers: [ 'Chrome', 'Firefox' ]
71                         }
72                 },
73                 copy: {
74                         jsduck: {
75                                 src: 'resources/**/*',
76                                 dest: 'docs/js/modules',
77                                 expand: true,
78                                 rename: function ( dest, src ) {
79                                         return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
80                                 }
81                         }
82                 }
83         } );
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"'
89                         );
90                 }
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"' );
94                 }
95                 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
96         } );
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' );