From: Timo Tijhof Date: Fri, 20 Mar 2015 02:09:17 +0000 (+0000) Subject: build: Add assert-mw-env task when running grunt-qunit X-Git-Tag: 1.31.0-rc.0~12039 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=2258f25053bb01ef7238ffcd32915b57e479040f;p=lhc%2Fweb%2Fwiklou.git build: Add assert-mw-env task when running grunt-qunit Previously it gave cryptic error messages like: > Running "karma" task > > Warning: Parameter 'url' must be a string, not number Change-Id: I0adb0f2f501dd5db2d6738a40efbce349f0175d2 --- diff --git a/Gruntfile.js b/Gruntfile.js index a292d0b377..5d6dc1788b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -97,8 +97,21 @@ module.exports = function ( grunt ) { } } ); + grunt.registerTask( 'assert-mw-env', function () { + if ( !process.env.MW_SERVER ) { + grunt.log.error( 'Environment variable MW_SERVER must be set.\n' + + 'Set this like $wgServer, e.g. "http://localhost"' + ); + } + if ( !process.env.MW_SCRIPT_PATH ) { + grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' + + 'Set this like $wgScriptPath, e.g. "/w"'); + } + return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); + } ); + grunt.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] ); - grunt.registerTask( 'qunit', 'karma:main' ); + grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); grunt.registerTask( 'test', ['lint'] ); grunt.registerTask( 'default', 'test' );