Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Configuration: move hasCorrectExtension to more appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
markelog committed Jun 21, 2016
1 parent 0d027a7 commit ea2c3f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 1 addition & 19 deletions lib/checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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 [];
}
Expand Down Expand Up @@ -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.
*
Expand Down
18 changes: 18 additions & 0 deletions lib/config/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit ea2c3f7

Please sign in to comment.