mediawiki-extensions-Confir.../Gruntfile.js
Timo Tijhof 2a47e936aa build: Simplify banana config with require() and for-of
* `require()` is more direct and likely faster than a synchronous
  file read into user land and then sync JSON.parse (as grunt.file
  does) than Node natively reading and parsing a file in one go.

  Also benefits being less Grunt-specific and theoretically some minor
  benefit to IDE and static analysis.

* Inline loop as for-of without the forEach function calls.

Change-Id: I06c8f8729b2f4ba2c574c7aaeaa2ae56513b4595
2023-09-20 09:28:46 +01:00

44 lines
990 B
JavaScript

/* eslint-env node */
module.exports = function ( grunt ) {
const messagesDirs = require( './extension.json' ).MessagesDirs;
for ( const subExtension of [
'QuestyCaptcha',
'ReCaptchaNoCaptcha',
'FancyCaptcha',
'MathCaptcha',
'hCaptcha'
] ) {
messagesDirs[ subExtension ] = require( './' + subExtension + '/extension.json' )
.MessagesDirs[ subExtension ]
.map( function ( path ) { return subExtension + '/' + path; } );
}
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.initConfig( {
eslint: {
options: {
cache: true,
fix: grunt.option( 'fix' )
},
all: [
'**/*.{js,json}',
'!{vendor,node_modules}/**'
]
},
stylelint: {
all: [
'**/*.{css,less}',
'!node_modules/**',
'!vendor/**'
]
},
banana: messagesDirs
} );
grunt.registerTask( 'test', [ 'eslint', 'stylelint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};