Comparing version 0.8.0 to 0.8.1
#!/usr/bin/env node | ||
/* jshint maxlen: 500 */ | ||
var fs = require('fs'), | ||
pth = require('path'), | ||
async = require('async'), | ||
@@ -11,2 +12,3 @@ chalk = require('chalk'), | ||
printDebug = mDebug.print, | ||
minimatch = require('minimatch'), | ||
startTime = Date.now(), | ||
@@ -218,5 +220,7 @@ dictionary = [], | ||
var fileExtensions = program.fileExtensions || json.fileExtensions; | ||
yaspeller.setParams({ | ||
maxRequests: program.maxRequests || json.maxRequests || 2, | ||
fileExtensions: program.fileExtensions || json.fileExtensions, | ||
fileExtensions: fileExtensions, | ||
excludeFiles: json.excludeFiles | ||
@@ -281,2 +285,3 @@ }); | ||
tasks.push(function(cb) { | ||
var ext; | ||
if(resource.search(/^https?:/) > -1) { | ||
@@ -295,2 +300,3 @@ if(resource.search(/sitemap\.xml$/) > -1) { | ||
if(fs.existsSync(resource)) { | ||
ext = pth.extname(resource).toLowerCase(); | ||
if(!yaspeller.isExcludedFile(resource)) { | ||
@@ -302,3 +308,3 @@ if(fs.statSync(resource).isDirectory()) { | ||
} else if(yaspeller.getRegExpFileExtensions().test(resource)) { | ||
} else if(!fileExtensions.length || fileExtensions.indexOf(ext) !== -1) { | ||
yaspeller.checkFile(resource, function(err, data) { | ||
@@ -305,0 +311,0 @@ onResource(err, data); |
@@ -72,4 +72,5 @@ /* jshint maxlen: 300 */ | ||
function isExcludedFile(file) { | ||
file = pth.resolve(file); | ||
for(var i = 0; i < params.excludeFiles.length; i++) { | ||
if(minimatch(file, params.excludeFiles[i])) { | ||
if(minimatch(file, pth.resolve('.', params.excludeFiles[i]), {dot: true})) { | ||
return true; | ||
@@ -82,9 +83,4 @@ } | ||
function getRegExpFileExtensions() { | ||
return new RegExp('(' + params.fileExtensions.join('|').replace(/\./g, '\\.') + ')$', 'i'); | ||
} | ||
function findFiles(dir) { | ||
var res = [], | ||
regExp = getRegExpFileExtensions(), | ||
isDir = function(dir) { | ||
@@ -96,3 +92,4 @@ return fs.statSync(dir).isDirectory(); | ||
files.forEach(function(el) { | ||
var file = pth.join(path, el); | ||
var file = pth.join(path, el), | ||
ext = pth.extname(file).toLowerCase(); | ||
if(isExcludedFile(file)) { | ||
@@ -104,3 +101,3 @@ return; | ||
find(file); | ||
} else if(regExp.test(file)) { | ||
} else if(!params.fileExtensions.length || params.fileExtensions.indexOf(ext) !== -1) { | ||
res.push(file); | ||
@@ -401,3 +398,2 @@ } | ||
}, | ||
getRegExpFileExtensions: getRegExpFileExtensions, | ||
isExcludedFile: isExcludedFile, | ||
@@ -404,0 +400,0 @@ checkText: checkText, |
@@ -10,3 +10,3 @@ { | ||
"description": "Search tool typos in the text, files and websites", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"license": "MIT", | ||
@@ -13,0 +13,0 @@ "homepage": "https://github.com/hcodes/yaspeller", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29663
650