From ea2c3f7020cc200cd93db409b1f01975b6cba7b4 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Tue, 21 Jun 2016 23:54:27 +0300 Subject: [PATCH] Configuration: move hasCorrectExtension to more appropriate place --- lib/checker.js | 20 +------------------- lib/config/configuration.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/checker.js b/lib/checker.js index 0ffd21148..81887545a 100644 --- a/lib/checker.js +++ b/lib/checker.js @@ -3,7 +3,6 @@ var Vow = require('vow'); var StringChecker = require('./string-checker'); var extractJs = require('./extract-js'); var utils = require('util'); -var path = require('path'); var NodeConfiguration = require('./config/node-configuration'); @@ -155,7 +154,7 @@ Checker.prototype._processDirectory = function(path, fileHandler) { return this._processDirectory(fullname, fileHandler); } - if (!this._hasCorrectExtension(fullname)) { + if (!this._configuration.hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } @@ -242,23 +241,6 @@ Checker.prototype._processStdin = function(stdinHandler) { return deferred.promise(); }; -/** - * Returns true if the file extension matches a file extension to process. - * - * @returns {Boolean} - */ -Checker.prototype._hasCorrectExtension = function(testPath) { - var extension = path.extname(testPath).toLowerCase(); - var basename = path.basename(testPath).toLowerCase(); - var fileExtensions = this._configuration.getFileExtensions(); - - return !( - fileExtensions.indexOf(extension) < 0 && - fileExtensions.indexOf(basename) < 0 && - fileExtensions.indexOf('*') < 0 - ); -}; - /** * Returns new configuration instance. * diff --git a/lib/config/configuration.js b/lib/config/configuration.js index 7e01a362e..b81708219 100644 --- a/lib/config/configuration.js +++ b/lib/config/configuration.js @@ -298,11 +298,29 @@ Configuration.prototype.getExcludedFileMasks = function() { */ Configuration.prototype.isFileExcluded = function(filePath) { filePath = path.resolve(filePath); + return this._excludedFileMatchers.some(function(matcher) { return matcher.match(filePath); }); }; +/** + * Returns true if the file extension matches a file extension to process. + * + * @returns {Boolean} + */ +Configuration.prototype.hasCorrectExtension = function(testPath) { + var extension = path.extname(testPath).toLowerCase(); + var basename = path.basename(testPath).toLowerCase(); + var fileExtensions = this.getFileExtensions(); + + return !( + fileExtensions.indexOf(extension) < 0 && + fileExtensions.indexOf(basename) < 0 && + fileExtensions.indexOf('*') < 0 + ); +}; + /** * Returns file extension list. *