Skip to content
This repository has been archived by the owner on Jan 6, 2018. It is now read-only.

Commit

Permalink
Merge pull request #10 from tikotzky/fix-issue-9
Browse files Browse the repository at this point in the history
Fix stripping of statements on the first line and last line
  • Loading branch information
Vijar committed Jan 9, 2016
2 parents 5020e42 + 00b0875 commit d5dc2a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function StripFnLoader(source) {

var toStrip = query.strip.join('|');

var regexPattern = new RegExp('\\n[ \\t]*(' + toStrip + ')\\([^\\);]+\\)[ \\t]*[;\\n]', 'g');
var regexPattern = new RegExp('(?:^|\\n)[ \\t]*(' + toStrip + ')\\([^\\);]+\\)[ \\t]*(?:$|[;\\n])', 'g');

var transformed = source.replace(regexPattern, '\n');

Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/app/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
console.log('a console.log on the first line should get stripped');
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
Expand All @@ -10,3 +11,4 @@ var makeFoo = function (bar, baz) {
// This code would remain
return new Foo(bar, baz);
};
console.log('a console.log on the last line without a semicolon should get stripped')

0 comments on commit d5dc2a1

Please sign in to comment.