Make sure Swift store operations close the source file handle
[mediawiki.git] / Gruntfile.js
blob0e1c8cb2c2826d4196cbb762ccf277d5cd7a8db1
1 /* eslint-env node */
3 module.exports = function ( grunt ) {
5         var wgServer = process.env.MW_SERVER,
6                 wgScriptPath = process.env.MW_SCRIPT_PATH,
7                 karmaProxy = {};
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 ] = {
18                 target: wgServer + wgScriptPath,
19                 changeOrigin: true
20         };
22         grunt.initConfig( {
23                 eslint: {
24                         all: [
25                                 '**/*.js',
26                                 '!docs/**',
27                                 '!node_modules/**',
28                                 '!resources/lib/**',
29                                 '!resources/src/jquery.tipsy/**',
30                                 '!resources/src/jquery/jquery.farbtastic.js',
31                                 '!resources/src/mediawiki.libs/**',
32                                 // Third-party code of PHPUnit coverage report
33                                 '!tests/coverage/**',
34                                 '!vendor/**',
35                                 // Explicitly say "**/*.js" here in case of symlinks
36                                 '!extensions/**/*.js',
37                                 '!skins/**/*.js',
38                                 // Skip functions aren't even parseable
39                                 '!resources/src/dom-level2-skip.js',
40                                 '!resources/src/es5-skip.js',
41                                 '!resources/src/mediawiki.hidpi-skip.js'
42                         ]
43                 },
44                 jsonlint: {
45                         all: [
46                                 '**/*.json',
47                                 '!{docs/js,extensions,node_modules,skins,vendor}/**'
48                         ]
49                 },
50                 banana: {
51                         options: {
52                                 disallowBlankTranslations: false
53                         },
54                         core: 'languages/i18n/',
55                         api: 'includes/api/i18n/',
56                         installer: 'includes/installer/i18n/'
57                 },
58                 stylelint: {
59                         options: {
60                                 syntax: 'less'
61                         },
62                         src: '{resources/src,mw-config}/**/*.{css,less}'
63                 },
64                 watch: {
65                         files: [
66                                 '.{stylelintrc,eslintrc.json}',
67                                 '**/*',
68                                 '!{docs,extensions,node_modules,skins,vendor}/**'
69                         ],
70                         tasks: 'test'
71                 },
72                 karma: {
73                         options: {
74                                 proxies: karmaProxy,
75                                 files: [ {
76                                         pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
77                                         watched: false,
78                                         included: true,
79                                         served: false
80                                 } ],
81                                 logLevel: 'DEBUG',
82                                 frameworks: [ 'qunit' ],
83                                 reporters: [ 'progress' ],
84                                 singleRun: true,
85                                 autoWatch: false,
86                                 // Some tests in extensions don't yield for more than the default 10s (T89075)
87                                 browserNoActivityTimeout: 60 * 1000
88                         },
89                         main: {
90                                 browsers: [ 'Chrome' ]
91                         },
92                         chromium: {
93                                 browsers: [ 'Chromium' ]
94                         },
95                         more: {
96                                 browsers: [ 'Chrome', 'Firefox' ]
97                         }
98                 },
99                 copy: {
100                         jsduck: {
101                                 src: 'resources/**/*',
102                                 dest: 'docs/js/modules',
103                                 expand: true,
104                                 rename: function ( dest, src ) {
105                                         return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
106                                 }
107                         }
108                 }
109         } );
111         grunt.registerTask( 'assert-mw-env', function () {
112                 if ( !process.env.MW_SERVER ) {
113                         grunt.log.error( 'Environment variable MW_SERVER must be set.\n' +
114                                 'Set this like $wgServer, e.g. "http://localhost"'
115                         );
116                 }
117                 if ( !process.env.MW_SCRIPT_PATH ) {
118                         grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
119                                 'Set this like $wgScriptPath, e.g. "/w"' );
120                 }
121                 return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH );
122         } );
124         grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] );
125         grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
127         grunt.registerTask( 'test', [ 'lint' ] );
128         grunt.registerTask( 'default', 'test' );