2013-05-31 02:33:12 +00:00
|
|
|
/*!
|
|
|
|
* Grunt file
|
|
|
|
*
|
|
|
|
* @package VisualEditor
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*jshint node:true */
|
|
|
|
module.exports = function ( grunt ) {
|
|
|
|
var fs = require( 'fs' ),
|
2013-12-14 23:04:08 +00:00
|
|
|
exec = require( 'child_process' ).exec,
|
|
|
|
modules = grunt.file.readJSON( 'build/modules.json' );
|
2013-05-31 02:33:12 +00:00
|
|
|
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
2013-12-06 02:34:44 +00:00
|
|
|
grunt.loadNpmTasks( 'grunt-jscs-checker' );
|
2013-12-14 23:04:08 +00:00
|
|
|
grunt.loadTasks( 'build/tasks' );
|
2013-05-31 02:33:12 +00:00
|
|
|
|
|
|
|
grunt.initConfig( {
|
|
|
|
pkg: grunt.file.readJSON( 'package.json' ),
|
2013-12-14 23:04:08 +00:00
|
|
|
buildloader: {
|
|
|
|
demo: {
|
|
|
|
src: 'demos/ve/index.php.template',
|
|
|
|
dest: 'demos/ve/index.php',
|
|
|
|
modules: modules,
|
|
|
|
pathPrefix: '../../',
|
|
|
|
indent: '\t\t'
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
src: 'modules/ve/test/index.php.template',
|
|
|
|
dest: 'modules/ve/test/index.php',
|
|
|
|
modules: modules,
|
|
|
|
pathPrefix: '../../../',
|
|
|
|
indent: '\t\t'
|
|
|
|
},
|
|
|
|
iframe: {
|
|
|
|
src: '.docs/eg-iframe.html.template',
|
|
|
|
dest: '.docs/eg-iframe.html',
|
|
|
|
modules: modules,
|
|
|
|
pathPrefix: '../',
|
|
|
|
indent: '\t'
|
|
|
|
}
|
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
jshint: {
|
|
|
|
options: JSON.parse( grunt.file.read( '.jshintrc' )
|
|
|
|
.replace( /\/\*(?:(?!\*\/)[\s\S])*\*\//g, '' ).replace( /\/\/[^\n\r]*/g, '' ) ),
|
2013-11-13 22:53:18 +00:00
|
|
|
all: ['*.js', 'modules/{syntaxhighlight,unicodejs,ve,ve-mw}/**/*.js']
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
2013-12-06 02:34:44 +00:00
|
|
|
jscs: {
|
|
|
|
src: [
|
|
|
|
'<%= jshint.all %>',
|
|
|
|
'!modules/syntaxhighlight/**/*.js',
|
|
|
|
'!modules/ve/test/ce/imetests/*.js'
|
|
|
|
]
|
|
|
|
},
|
2013-05-31 02:33:12 +00:00
|
|
|
csslint: {
|
|
|
|
options: {
|
|
|
|
csslintrc: '.csslintrc'
|
|
|
|
},
|
2013-12-03 22:09:56 +00:00
|
|
|
// TODO: modules/syntaxhighlight should be included, but is failing.
|
|
|
|
all: ['demos/**/*.css', 'modules/{ve,ve-mw}/**/*.css'],
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
|
|
|
qunit: {
|
2013-11-13 22:53:18 +00:00
|
|
|
ve: 'modules/ve/test/index-phantomjs-tmp.html'
|
2013-05-31 02:33:12 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2013-12-03 22:09:56 +00:00
|
|
|
files: ['<%= jshint.all %>', '<%= csslint.all %>', '<%= qunit.ve %>', '.{jshintrc,jshintignore,csslintrc}'],
|
2013-05-31 02:33:12 +00:00
|
|
|
tasks: ['test']
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
grunt.registerTask( 'pre-qunit', function () {
|
|
|
|
var done = this.async();
|
|
|
|
grunt.file.setBase( __dirname + '/modules/ve/test' );
|
|
|
|
exec( 'php index.php > index-phantomjs-tmp.html', function ( err, stdout, stderr ) {
|
|
|
|
if ( err || stderr ) {
|
|
|
|
grunt.log.error( err || stderr );
|
|
|
|
done( false );
|
|
|
|
} else {
|
|
|
|
grunt.file.setBase( __dirname );
|
|
|
|
done( true );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2013-06-14 11:24:31 +00:00
|
|
|
grunt.event.on( 'qunit.done', function () {
|
2013-05-31 02:33:12 +00:00
|
|
|
fs.unlinkSync( __dirname + '/modules/ve/test/index-phantomjs-tmp.html' );
|
|
|
|
} );
|
|
|
|
|
2013-12-06 02:34:44 +00:00
|
|
|
grunt.registerTask( 'lint', ['jshint', 'jscs', 'csslint'] );
|
2013-06-14 11:24:31 +00:00
|
|
|
grunt.registerTask( 'unit', ['pre-qunit', 'qunit'] );
|
|
|
|
grunt.registerTask( 'test', ['lint', 'unit'] );
|
2013-12-14 23:04:08 +00:00
|
|
|
grunt.registerTask( 'build', ['buildloader'] );
|
|
|
|
grunt.registerTask( 'default', ['build', 'test'] );
|
2013-05-31 02:33:12 +00:00
|
|
|
};
|