grunt-time-bomb
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,0 +0,0 @@ /* |
{ | ||
"name": "grunt-time-bomb", | ||
"description": "Detect time bombs in source code comments.", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"homepage": "https://github.com/tobiashennig/grunt-time-bomb", | ||
@@ -36,3 +36,3 @@ "author": { | ||
"peerDependencies": { | ||
"grunt": "~0.4.5" | ||
"grunt": ">=0.4.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "keywords": [ |
@@ -68,2 +68,3 @@ # grunt-time-bomb | ||
## Release History | ||
* [0.1.3] Update peer dependency to support Grunt 1.0, fix #1, #2 | ||
* [0.1.0] Initial version |
@@ -7,4 +7,4 @@ var acorn = require('acorn'); | ||
this.key = '@timer'; | ||
this.testRegExp = new RegExp(this.key + '\\s', 'i'); | ||
this.dateRegExp = new RegExp(this.key + '\\s+(\\d{4}-\\d{2}-\\d{2})', 'i'); | ||
this.testRegExp = new RegExp(this.key + '[^\\w]', 'i'); | ||
this.dateRegExp = new RegExp(this.key + '[^\\w]+(\\d{4}-\\d{2}-\\d{2})', 'i'); | ||
this.timers = new Timers(); | ||
@@ -15,15 +15,14 @@ } | ||
var comments = [], options = {}; | ||
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); | ||
files.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); | ||
@@ -30,0 +29,0 @@ }; |
@@ -0,0 +0,0 @@ function Timer(file, date) { |
@@ -0,0 +0,0 @@ var Timer = require('./timer'); |
@@ -16,3 +16,3 @@ /* | ||
var bd = new BombDetector(); | ||
bd.parse(this.files); | ||
bd.parse(this.filesSrc); | ||
var timers = bd.timers.get(), bombs = bd.timers.bombs(); | ||
@@ -25,5 +25,5 @@ | ||
} else if (bombs.length > 0) { | ||
grunt.fatal('Exploded time bomb found in file: ' + bombs[0].file); | ||
grunt.fail.warn('Exploded time bomb found in file: ' + bombs[0].file); | ||
} | ||
}); | ||
}; |
@@ -28,4 +28,5 @@ // @timer 1990-01-01 | ||
// @timer 2100-01-04 | ||
// @timer: 2100-01-04 | ||
// @Timer 2100-01-05 | ||
// @timerr 2100-01-01 |
'use strict'; | ||
var path = require('path'); | ||
var grunt = require('grunt'); | ||
var BombDetector = require('../tasks/lib/bomb-detector')(grunt); | ||
var fixtures = path.join(__dirname, 'fixtures'); | ||
/* | ||
@@ -28,3 +31,3 @@ ======== A Handy Little Nodeunit Reference ======== | ||
setUp: function(done) { | ||
this.files = [{ src: 'test/fixtures/testing.js' }]; | ||
this.files = [path.join(fixtures, 'testing.js')]; | ||
this.bd = new BombDetector(); | ||
@@ -40,3 +43,3 @@ this.bd.parse(this.files); | ||
test.equal(timers.length, 7, 'should detect all timers'); | ||
test.equal(timers.length, 8, 'should detect all timers'); | ||
test.equal(bombs.length, 2, 'should detect all bombs'); | ||
@@ -43,0 +46,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10148
199
70