From 198d51ddaadb3b68b6ecb2dc20b29d07572df0b8 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 15 May 2015 01:34:58 +0100 Subject: [PATCH] heavily improve shouldIgnore algorithm - fixes #1539 --- src/babel/util.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/babel/util.js b/src/babel/util.js index 6b03bc0aa0..021e5b4a9b 100644 --- a/src/babel/util.js +++ b/src/babel/util.js @@ -95,7 +95,26 @@ export function booleanify(val: any): boolean { } export function shouldIgnore(filename, ignore, only) { + if (!ignore.length && !only.length) return false; + filename = slash(filename); + + // try and match each section of the path + var parts = filename.split("/"); + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (!part) continue; + + if (_shouldIgnore(part, ignore, only) || + _shouldIgnore(parts.slice(0, i + 1).join("/"), ignore, only)) { + return true; + } + } + + return false; +} + +function _shouldIgnore(filename, ignore, only) { if (only.length) { for (var pattern of (only: Array)) { if (pattern.test(filename)) return false;