Minor doc fixes
[mediawiki.git] / Gruntfile.js
bloba292d0b377552179650de926530b5d880dc915a7
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                 pkg: grunt.file.readJSON( 'package.json' ),
19                 jshint: {
20                         options: {
21                                 jshintrc: true
22                         },
23                         all: [
24                                 '*.js',
25                                 '{includes,languages,resources,tests}/**/*.js'
26                         ]
27                 },
28                 jscs: {
29                         all: [
30                                 '<%= jshint.all %>',
31                                 // Auto-generated file with JSON (double quotes)
32                                 '!tests/qunit/data/mediawiki.jqueryMsg.data.js',
33                                 // Skip functions are stored as script files but wrapped in a function when
34                                 // executed. node-jscs trips on the would-be "Illegal return statement".
35                                 '!resources/src/*-skip.js'
37                         // Exclude all files ignored by jshint
38                         ].concat( grunt.file.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns, pattern ) {
39                                 // Filter out empty lines
40                                 if ( pattern.length && pattern[0] !== '#' ) {
41                                         patterns.push( '!' + pattern );
42                                 }
43                                 return patterns;
44                         }, [] ) )
45                 },
46                 jsonlint: {
47                         all: [
48                                 '.jscsrc',
49                                 '{languages,maintenance,resources}/**/*.json',
50                                 'package.json'
51                         ]
52                 },
53                 banana: {
54                         core: 'languages/i18n/',
55                         api: 'includes/api/i18n/',
56                         installer: 'includes/installer/i18n/'
57                 },
58                 watch: {
59                         files: [
60                                 '<%= jscs.all %>',
61                                 '<%= jsonlint.all %>',
62                                 '.jshintignore',
63                                 '.jshintrc'
64                         ],
65                         tasks: 'test'
66                 },
67                 karma: {
68                         options: {
69                                 proxies: karmaProxy,
70                                 files: [ {
71                                         pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
72                                         watched: false,
73                                         included: true,
74                                         served: false
75                                 } ],
76                                 frameworks: [ 'qunit' ],
77                                 reporters: [ 'dots' ],
78                                 singleRun: true,
79                                 autoWatch: false
80                         },
81                         main: {
82                                 browsers: [ 'Chrome' ]
83                         },
84                         more: {
85                                 browsers: [ 'Chrome', 'Firefox' ]
86                         }
87                 },
88                 copy: {
89                         jsduck: {
90                                 src: 'resources/**/*',
91                                 dest: 'docs/js/modules',
92                                 expand: true,
93                                 rename: function ( dest, src ) {
94                                         return require( 'path' ).join( dest, src.replace( 'resources/', '' ) );
95                                 }
96                         }
97                 }
98         } );
100         grunt.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] );
101         grunt.registerTask( 'qunit', 'karma:main' );
103         grunt.registerTask( 'test', ['lint'] );
104         grunt.registerTask( 'default', 'test' );