Skip to content

Commit

Permalink
tweak comment stripping to grab block comments at the end of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
rossPatton committed Jun 11, 2015
1 parent e03dfa8 commit ef87046
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lib-cov
*.out
*.pid
*.gz
.DS_Store

pids
logs
Expand Down
5 changes: 2 additions & 3 deletions src/parse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var fs = require('fs');
var stripCommentsRe = /(^(\/\*)|([ \t'"](\/\*)))(?!\/)(.|[\r\n]|\n)+?\*\/\n?\n?/gm;


/**
Expand All @@ -11,14 +12,12 @@ var fs = require('fs');
* @returns test function
*/
module.exports = function parse( app, file, len, fileNum ) {
var stripComments = /(^(\/\*)|^([ \t](\/\*)))(?!\/)(.|[\r\n]|\n)+?\*\/\n?\n?/gm;

return fs.readFile(file, { encoding: 'utf8' }, function( err, data ) {
if ( err ) { throw err; }
var lines;

// remove block comments / empty lines from files
lines = data.replace(stripComments, function( match ) {
lines = data.replace(stripCommentsRe, function( match ) {
var lines = match.split(/\r\n|\r|\n/),
lineLen = lines.length - 1,
output = ' ';
Expand Down

0 comments on commit ef87046

Please sign in to comment.