From c8b8ef5610551fef320624082f427008a00ecae3 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 28 Jul 2014 16:01:55 -0400 Subject: [PATCH 1/2] Support config.preprocessorIgnorePatterns. This is useful for not processing the contents of e.g. node_modules. --- src/lib/utils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index 744138899d6d..9fb91e15d94b 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -18,6 +18,7 @@ var DEFAULT_CONFIG_VALUES = { globals: {}, moduleFileExtensions: ['js', 'json'], moduleLoader: require.resolve('../HasteModuleLoader/HasteModuleLoader'), + preprocessorIgnorePatterns: [], modulePathIgnorePatterns: [], testDirectoryName: '__tests__', testEnvironment: require.resolve('../JSDomEnvironment'), @@ -193,6 +194,7 @@ function normalizeConfig(config) { )); break; + case 'preprocessorIgnorePatterns': case 'testPathIgnorePatterns': case 'modulePathIgnorePatterns': case 'unmockedModulePathPatterns': @@ -329,7 +331,10 @@ function readAndPreprocessFileContent(filePath, config) { fileData = fileData.replace(/^#!.*/, ''); } - if (config.scriptPreprocessor) { + if (config.scriptPreprocessor && + !config.preprocessorIgnorePatterns.some(function(pattern) { + return filePath.indexOf(pattern) >= 0; + })) { try { fileData = require(config.scriptPreprocessor).process(fileData, filePath); } catch (e) { From f4a68711f8599f02dfc06d1147d66eedc5269763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Thu, 12 Mar 2015 11:16:55 -0700 Subject: [PATCH 2/2] Use //.test --- src/lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index 9fb91e15d94b..f167c1c0f012 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -333,7 +333,7 @@ function readAndPreprocessFileContent(filePath, config) { if (config.scriptPreprocessor && !config.preprocessorIgnorePatterns.some(function(pattern) { - return filePath.indexOf(pattern) >= 0; + return pattern.test(filePath); })) { try { fileData = require(config.scriptPreprocessor).process(fileData, filePath);