diff --git a/grunt.js b/Gruntfile.js similarity index 66% rename from grunt.js rename to Gruntfile.js index aea0db9..1d9c8b7 100644 --- a/grunt.js +++ b/Gruntfile.js @@ -3,57 +3,42 @@ module.exports = function( grunt ) { "use strict"; +var files = [ + "jquery.simulate.js", + "Gruntfile.js", + "test/*.js", + "test/unit/*.js" +]; + grunt.loadNpmTasks( "grunt-update-submodules" ); grunt.loadNpmTasks( "grunt-compare-size" ); grunt.loadNpmTasks( "grunt-git-authors" ); +grunt.loadNpmTasks( "grunt-contrib-qunit" ); +grunt.loadNpmTasks( "grunt-contrib-uglify" ); +grunt.loadNpmTasks( "grunt-contrib-jshint" ); grunt.initConfig({ - pkg: "", - - meta: { - banner: "/*! jQuery Simulate v@<%= pkg.version %> http://github.com/jquery/jquery-simulate | jquery.org/license */" - }, + pkg: grunt.file.readJSON( "package.json" ), - lint: { - src: [ "jquery.simulate.js" ], - grunt: "grunt.js", - test: [ "test/*.js", "test/unit/*.js" ] + jshint: { + options: { + jshintrc: true + }, + all: files }, - jshint: (function() { - function parserc( path ) { - var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), - settings = { - options: rc, - globals: rc.globals || {} - }; - - (rc.predef || []).forEach(function( prop ) { - settings.globals[ prop ] = true; - }); - delete rc.predef; - - return settings; - } - - return { - src: parserc(), - grunt: parserc(), - test: parserc( "test/" ) - }; - })(), - qunit: { files: "test/index.html" }, - min: { - "dist/jquery.simulate.min.js": [ "", "dist/jquery.simulate.js" ] - }, - - watch: { - files: [ "", "", "" ], - tasks: "default" + uglify: { + options: { + banner: "/*! jQuery Simulate v@<%= pkg.version %> http://github.com/jquery/jquery-simulate | jquery.org/license */" + }, + build: { + src: "dist/jquery.simulate.js", + dest: "dist/jquery.simulate.min.js" + } }, compare_size: { @@ -61,10 +46,8 @@ grunt.initConfig({ } }); - - -grunt.registerHelper( "git-date", function( fn ) { - grunt.utils.spawn({ +function git_date( fn ) { + grunt.util.spawn({ cmd: "git", args: [ "log", "-1", "--pretty=format:%ad" ] }, function( error, result ) { @@ -75,7 +58,7 @@ grunt.registerHelper( "git-date", function( fn ) { fn( null, result ); }); -}); +} grunt.registerTask( "max", function() { var dist = "dist/jquery.simulate.js", @@ -86,7 +69,7 @@ grunt.registerTask( "max", function() { version += " " + process.env.COMMIT; } - grunt.helper( "git-date", function( error, date ) { + git_date(function( error, date ) { if ( error ) { return done( false ); } @@ -143,7 +126,7 @@ grunt.registerTask( "manifest", function() { }, null, "\t" ) ); }); -grunt.registerTask( "default", "lint update_submodules qunit build compare_size" ); -grunt.registerTask( "build", "max min" ); +grunt.registerTask( "default", ["jshint", "update_submodules", "qunit", "build", "compare_size"] ); +grunt.registerTask( "build", ["max", "uglify"] ); }; diff --git a/package.json b/package.json index 702f24c..0d63a08 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,21 @@ "url": "https://github.com/jquery/jquery-simulate/blob/master/MIT-LICENSE.txt" } ], - "dependencies": {}, "devDependencies": { - "grunt": "~0.3.17", - "grunt-compare-size": "0.1.4", - "grunt-git-authors": "1.0.0", - "grunt-update-submodules": "0.1.2", - "testswarm": "0.2.2" + "grunt": "0.4.1", + "grunt-contrib-qunit": "0.3.0", + "grunt-contrib-uglify": "0.2.7", + "grunt-compare-size": "0.4.0-rc.3", + "grunt-git-authors": "1.2.0", + "grunt-update-submodules": "0.2.0", + "testswarm": "1.1.0", + "grunt-contrib-jshint": "0.7.1" }, - "keywords": [ "simulate", "events", "keyboard", "mouse", "jquery" ] -} \ No newline at end of file + "keywords": [ + "simulate", + "events", + "keyboard", + "mouse", + "jquery" + ] +} diff --git a/test/.jshintrc b/test/.jshintrc index 1784fd1..2ca2b0e 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -13,18 +13,18 @@ "trailing": true, "undef": true, "unused": true, - "predef": [ - "asyncTest", - "deepEqual", - "equal", - "expect", - "module", - "notEqual", - "ok", - "QUnit", - "start", - "stop", - "strictEqual", - "test" - ] + "globals": { + "asyncTest": false, + "deepEqual": false, + "equal": false, + "expect": false, + "module": false, + "notEqual": false, + "ok": false, + "QUnit": false, + "start": false, + "stop": false, + "strictEqual": false, + "test": false + } }