diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..3acb72b --- /dev/null +++ b/.jshintrc @@ -0,0 +1,14 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "node": true, + "globals": {} +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index c04c9bb..f166214 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,35 +1,26 @@ module.exports = function(grunt) { + var config = { + files: [ "Gruntfile.js", "tasks/**/*.js", "test/**/*.js" ] + }; + // Project configuration. grunt.initConfig({ nodeunit: { all: ["test/**/*.js"] }, watch: { - files: "", + files: config.files, tasks: "default" }, jshint: { - all: ["grunt.js", "tasks/**/*.js", "test/**/*.js"], - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - globals: {} - } + all: config.files } }); grunt.loadNpmTasks("grunt-contrib-jshint"); grunt.loadNpmTasks("grunt-contrib-nodeunit"); + grunt.loadNpmTasks("grunt-contrib-watch"); grunt.registerTask("default", ["jshint", "nodeunit"]); }; diff --git a/package.json b/package.json index d6ae8b7..ebd47e0 100644 --- a/package.json +++ b/package.json @@ -1,39 +1,45 @@ { - "name" : "grunt-remove-logging", - "description" : "Grunt task to remove console logging statements", - "version" : "0.2.0", - "homepage" : "", - "author" : { - "name" : "Eric Hynds", - "email" : "ehynds@gmail.com", - "url" : "http://erichynds.com" + "name": "grunt-remove-logging", + "description": "Grunt task to remove console logging statements", + "version": "0.2.0", + "homepage": "", + "author": { + "name": "Eric Hynds", + "email": "ehynds@gmail.com", + "url": "http://erichynds.com" }, "contributors": { "name": "Thomas Welton", "email": "thomaswelton@me.com", "url": "https://github.com/thomaswelton" }, - "repository" : { - "type" : "git", - "url" : "git://github.com/ehynds/grunt-remove-logging.git" + "repository": { + "type": "git", + "url": "git://github.com/ehynds/grunt-remove-logging.git" }, - "bugs" : { - "url" : "https://github.com/ehynds/grunt-remove-logging/issues" + "bugs": { + "url": "https://github.com/ehynds/grunt-remove-logging/issues" }, - "main" : "grunt.js", - "bin" : "bin/grunt-remove-logging", - "engines" : { - "node" : "*" + "main": "grunt.js", + "bin": "bin/grunt-remove-logging", + "engines": { + "node": "*" }, - "scripts" : { - "test" : "grunt test" + "scripts": { + "test": "grunt test" }, - "devDependencies" : { - "grunt" : "~0.4.2", + "devDependencies": { + "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.7.2", - "grunt-contrib-nodeunit": "~0.2.2" + "grunt-contrib-nodeunit": "~0.2.2", + "grunt-contrib-watch": "~0.5.3" }, - "keywords" : [ - "gruntplugin", "console", "log", "debugging", "remove", "statements" + "keywords": [ + "gruntplugin", + "console", + "log", + "debugging", + "remove", + "statements" ] } diff --git a/test/test.js b/test/test.js index 7810891..1258edb 100644 --- a/test/test.js +++ b/test/test.js @@ -1,226 +1,163 @@ -"use strict"; - -var grunt = require("grunt"); -var task = require("../tasks/lib/removelogging").init(grunt); -var async = grunt.util.async; - -// each item in the array is a test. -// the convention is: -// [ -// string to test, -// options to pass to the remove_logging helper -// expected result -// ] -var tests = [ - [ - 'console.log(foo); bar; console.warn("bar")', - {}, - " bar; " - ], - [ - 'console.dir({ complex: "objects" }, [ "array" ])', - {}, - "" - ], - [ - 'console.log("foo (inner parens)")', - {}, - "" - ], - [ - 'console.log("foo (inner parens)");foo;console.warn("(lol)")', - {}, - "foo;" - ], - [ - ';if(true){functionCall(function namedFun(){console.log("test", args);})};for(var x=1;x