From 5d31d5b8228fe427d5ce924060e1a2eed0a5c298 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Fri, 22 Feb 2019 10:46:13 -0800 Subject: [PATCH] Improve handling of .gitignore files. * Omit comments from list of patterns. * Support .gitignore files with \r\n linebreaks. --- src/ignoreFiles.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ignoreFiles.js b/src/ignoreFiles.js index 9f0c9a88..4511f49b 100644 --- a/src/ignoreFiles.js +++ b/src/ignoreFiles.js @@ -12,7 +12,7 @@ const matchers = []; * @see {@linkplain https://git-scm.com/docs/gitignore#_pattern_format} */ function addIgnorePattern(val) { - if (val && typeof val === 'string') { + if (val && typeof val === 'string' && val[0] !== '#') { let pattern = val; if (pattern.indexOf('/') === -1) { matchers.push('**/' + pattern); @@ -51,7 +51,7 @@ function addIgnoreFromFile(input) { const stats = fs.statSync(config); if (stats.isFile()) { const content = fs.readFileSync(config, 'utf8'); - lines = lines.concat(content.split('\n')); + lines = lines.concat(content.split(/\r?\n/)); } });