grunt-time-bomb
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "grunt-time-bomb", | ||
"description": "Detect time bombs in source code comments.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/tobiashennig/grunt-time-bomb", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -14,13 +14,22 @@ var acorn = require('acorn'); | ||
var comments = [], options = {}; | ||
files.forEach(function(file) { | ||
comments = options.onComment = []; | ||
acorn.parse(grunt.file.read(file.src), options); | ||
this.parseComments(file, comments); | ||
files.forEach(function(file) { | ||
file.src.filter(function(filepath) { | ||
// Remove nonexistent files (it's up to you to filter or warn here). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
return false; | ||
} | ||
return true; | ||
}).map(function(filepath){ | ||
comments = options.onComment = []; | ||
acorn.parse(grunt.file.read(filepath), options); | ||
this.parseComments(filepath, comments); | ||
}, this); | ||
}, this); | ||
}; | ||
BombDetector.prototype.parseComments = function(file, comments) { | ||
BombDetector.prototype.parseComments = function(filepath, comments) { | ||
comments.forEach(function(comment) { | ||
if (this.isTimer(comment)) { | ||
this.timers.add(file.src, this.getDateFromTimer(comment)); | ||
this.timers.add(filepath, this.getDateFromTimer(comment)); | ||
} | ||
@@ -27,0 +36,0 @@ }, this); |
@@ -17,3 +17,3 @@ /* | ||
bd.parse(this.files); | ||
var timers = bd.timers.get(), bombs = timers.bombs(); | ||
var timers = bd.timers.get(), bombs = bd.timers.bombs(); | ||
@@ -20,0 +20,0 @@ if (timers.length === 0) { |
9408
198