Couto / groundskeeper

node.js package to remove forgotten console statements and specific blocks of code from you Javascript files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trailing directives break groundskeeper

betaorbust opened this issue · comments

Currently, groundskeeper just matches on /^[<]([/]([^\s])[>]$/ for any pragma and then does an every-other pass to decide what to strip out. If there's a trailing open directive, everything breaks because of the while(ranges.length) block calling ranges.shift twice.

console.log('keep me!');
if(foo){
    //<pragma>
    console.log('oops!'); 
}

Causes
turns into:

console.log('keep me!');
if(foo){

The fix will be to just change it to while(ranges.length > 1) and ignore the broken pragmas.