diff --git a/CHANGELOG.md b/CHANGELOG.md index 846f271..ae07f1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,3 +7,7 @@ ## 0.0.1 - Fixed package.json dependency + +## 0.0.2 + +- Using regex to match start of function inside gulpfile.js diff --git a/index.js b/index.js index 1bc650a..735426b 100644 --- a/index.js +++ b/index.js @@ -21,12 +21,21 @@ module.exports = function(gulp) { start, end, comment, - deps; + deps, + regex, + fnPos; for (taskName in gulp.tasks) { if (gulp.tasks.hasOwnProperty(taskName)) { - start = gulpfileCode.lastIndexOf("//", gulpfileCode.indexOf(gulp.tasks[taskName].fn.toString())); + if(taskName == 'task-list') continue; + + regex = 'gulp\\.task\\s*\\(\\s*[\\\'"]' + taskName + '[\\\'"]'; + fnPos = gulpfileCode.search(new RegExp(regex)); + + if(fnPos == -1) continue; + + start = gulpfileCode.lastIndexOf("//", fnPos); end = gulpfileCode.indexOf('\n', start); if (start !== -1 && end !== -1) { start += 2; diff --git a/package.json b/package.json index fe49673..303b7ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-task-list", - "version": "0.0.1", + "version": "0.0.2", "description": "Lists gulp tasks and their comments", "main": "index.js", "repository": {