From 4fbc836b69bb001e365ef0706e654ada75b3fa9c Mon Sep 17 00:00:00 2001 From: Taylor Hunt Date: Wed, 31 Jul 2019 16:24:46 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20comments=20from=20.gitig?= =?UTF-8?q?nore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a `.gitignore` file has comment lines, `browser-refresh` will announce them as patterns, like so: ```sh $ browser-refresh index.js [browser-refresh] Watching: /Users/me/git/project [browser-refresh] Ignore rule: #### MacOS #### [browser-refresh] Ignore rule: .DS_Store [browser-refresh] Ignore rule: .AppleDouble [browser-refresh] Ignore rule: .LSOverride [browser-refresh] Ignore rule: # Icon must end with two \r [browser-refresh] Ignore rule: Icon [browser-refresh] Ignore rule: # Thumbnails [browser-refresh] Ignore rule: ._* [browser-refresh] Ignore rule: #### Node.JS #### ``` I’m unsure this is the place to filter them out, though — _technically_ a filename can start with the gitconfig comment characters (`#` and `;`). I couldn’t find the code that parses out patterns from `.gitignore`, but if you show me where I’ll filter there instead! --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 8751f21..9628a24 100644 --- a/lib/index.js +++ b/lib/index.js @@ -161,7 +161,9 @@ exports.start = function(config) { logger.info('Watching: ' + dir); }); - eventArgs.ignorePatterns.forEach(function(pattern) { + eventArgs.ignorePatterns.filter(function(pattern) { + return ! /^[#;]/.test(pattern); // don't show comments from .gitignore + }).forEach(function(pattern) { logger.info('Ignore rule: ' + pattern); }); }) @@ -240,4 +242,4 @@ exports.start = function(config) { }); return launcher; -}; \ No newline at end of file +};