Comparing version 3.2.0 to 3.3.0
# Changelog | ||
# 3.2.0 | ||
## 3.3.0 | ||
- Glob patterns for Windows | ||
- Updated deps in package.json | ||
## 3.2.0 | ||
- File extension with multiple dots #66, #67 @levonet | ||
# 3.1.0 | ||
## 3.1.0 | ||
- Remove acute accent, shy and other symbols #65 | ||
@@ -24,3 +28,3 @@ - Updated deps in package.json | ||
## 2.9.0 | ||
## 2.9.0 | ||
- Ability to ignore the text using regular expressions (`--ignore-text` for CLI or `ignoreText` for `.yaspellerrc`) | ||
@@ -48,7 +52,5 @@ - Updated deps in package.json | ||
## 2.5.1 | ||
- Updated deps in package.json | ||
## 2.5.0 | ||
@@ -55,0 +57,0 @@ - Replace npm module `eyo` to `eyo-kernel` |
167
lib/tasks.js
@@ -11,2 +11,3 @@ 'use strict'; | ||
const yaspeller = require('./yaspeller'); | ||
const glob = require('glob'); | ||
@@ -39,2 +40,24 @@ function hasData(err, data) { | ||
/** | ||
* Expand glob arguments. | ||
* | ||
* @param {string[]} args | ||
* @return {string[]} | ||
*/ | ||
expandGlobArgs(args) { | ||
let result = []; | ||
for (const value of args) { | ||
if (utils.isUrl(value)) { | ||
result.push(value); | ||
} else { | ||
const files = glob.sync(value); | ||
if (files) { | ||
result = result.concat(files); | ||
} | ||
} | ||
} | ||
return result; | ||
}, | ||
/** | ||
* Prepare tasks for resources. | ||
@@ -47,55 +70,14 @@ * | ||
forResources(resources, settings) { | ||
const tasks = []; | ||
resources.forEach(function(resource) { | ||
tasks.push(function(cb) { | ||
const subTasks = []; | ||
if (utils.isUrl(resource)) { | ||
if (utils.isSitemap(resource)) { | ||
yaspeller.checkSitemap(resource, function() { | ||
cb(); | ||
}, settings, onResource); | ||
} else { | ||
yaspeller.checkUrl(resource, function(err, data, originalText) { | ||
onResource(err, data, originalText); | ||
cb(); | ||
}, settings); | ||
} | ||
return this.expandGlobArgs(resources).map(resource => callback => { | ||
if (utils.isUrl(resource)) { | ||
this.forUrl(resource, settings, callback); | ||
} else { | ||
if (fs.existsSync(resource)) { | ||
this.forFiles(resource, settings, callback); | ||
} else { | ||
if (fs.existsSync(resource)) { | ||
if (utils.isDir(resource)) { | ||
utils | ||
.findFiles(resource, settings.fileExtensions, settings.excludeFiles) | ||
.forEach(function(file) { | ||
subTasks.push(function(subcb) { | ||
yaspeller.checkFile(file, function(err, data, originalText) { | ||
onResource(err, data, originalText); | ||
subcb(); | ||
}, settings); | ||
}); | ||
}); | ||
async.parallelLimit(subTasks, settings.maxRequests, function() { | ||
cb(); | ||
}); | ||
} else { | ||
const file = pth.resolve(resource); | ||
if (utils.isExcludedFile(file, settings.excludeFiles)) { | ||
cb(); | ||
} else { | ||
yaspeller.checkFile(file, function(err, data, originalText) { | ||
onResource(err, data, originalText); | ||
cb(); | ||
}, settings); | ||
} | ||
} | ||
} else { | ||
onResource(true, Error(resource + ': is not exists')); | ||
cb(); | ||
} | ||
onResource(true, Error(`${resource}: is not exists`)); | ||
callback(); | ||
} | ||
}); | ||
} | ||
}); | ||
return tasks; | ||
}, | ||
@@ -109,23 +91,76 @@ /** | ||
forStdin(settings) { | ||
return [function(cb) { | ||
return [function(callback) { | ||
let text = ''; | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin | ||
.setEncoding('utf8') | ||
.on('readable', () => { | ||
const chunk = process.stdin.read(); | ||
if (chunk !== null) { | ||
text += chunk; | ||
} | ||
}) | ||
.on('end', function() { | ||
const startTime = Date.now(); | ||
yaspeller.checkText(text, (err, data, originalText) => { | ||
onResource( | ||
err, | ||
err ? data : { | ||
resource: 'stdin', | ||
data: data, | ||
time: Date.now() - startTime | ||
}, | ||
originalText | ||
); | ||
callback(); | ||
}, settings); | ||
}); | ||
}]; | ||
}, | ||
/** | ||
* Prepare tasks for files. | ||
* | ||
* @param {string} resource | ||
* @param {Object} settings | ||
* @param {Function} callback | ||
*/ | ||
forFiles(resource, settings, callback) { | ||
if (utils.isDir(resource)) { | ||
const tasks = utils | ||
.findFiles(resource, settings.fileExtensions, settings.excludeFiles) | ||
.map(file => cb => yaspeller.checkFile(file, (err, data, originalText) => { | ||
onResource(err, data, originalText); | ||
cb(); | ||
}, settings)); | ||
process.stdin.on('readable', function() { | ||
const chunk = process.stdin.read(); | ||
if (chunk !== null) { | ||
text += chunk; | ||
} | ||
}); | ||
process.stdin.on('end', function() { | ||
const startTime = Date.now(); | ||
yaspeller.checkText(text, function(err, data, originalText) { | ||
onResource(err, err ? data : {resource: 'stdin', data: data, time: Date.now() - startTime}, originalText); | ||
cb(); | ||
async.parallelLimit(tasks, settings.maxRequests, callback); | ||
} else { | ||
const file = pth.resolve(resource); | ||
if (utils.isExcludedFile(file, settings.excludeFiles)) { | ||
callback(); | ||
} else { | ||
yaspeller.checkFile(file, (err, data, originalText) => { | ||
onResource(err, data, originalText); | ||
callback(); | ||
}, settings); | ||
}); | ||
}]; | ||
} | ||
} | ||
}, | ||
/** | ||
* Prepare tasks for a url. | ||
* | ||
* @param {string} resource | ||
* @param {Object} settings | ||
* @param {Function} callback | ||
*/ | ||
forUrl(resource, settings, callback) { | ||
if (utils.isSitemap(resource)) { | ||
yaspeller.checkSitemap(resource, callback, settings, onResource); | ||
} else { | ||
yaspeller.checkUrl(resource, (err, data, originalText) => { | ||
onResource(err, data, originalText); | ||
callback(); | ||
}, settings); | ||
} | ||
} | ||
}; |
@@ -5,4 +5,4 @@ 'use strict'; | ||
const entities = require('entities'); | ||
const eyo = require('eyo-kernel'); | ||
const fs = require('fs'); | ||
const eyo = require('./eyo'); | ||
const formatModule = require('./format'); | ||
@@ -112,3 +112,3 @@ const ignore = require('./ignore'); | ||
function checkYo(text, data) { | ||
eyo.lint(text, true).safe.forEach(function(el) { | ||
eyo(text).forEach(function(el) { | ||
data.push({ | ||
@@ -115,0 +115,0 @@ code: 100, |
@@ -13,3 +13,3 @@ { | ||
"description": "Search tool typos in the text, files and websites", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"license": "MIT", | ||
@@ -36,23 +36,24 @@ "homepage": "https://github.com/hcodes/yaspeller", | ||
"dependencies": { | ||
"async": "~2.1.5", | ||
"chalk": "~1.1.3", | ||
"commander": "~2.9.0", | ||
"eyo-kernel": "~1.0.6", | ||
"entities": "~1.1.1", | ||
"isutf8": "~2.0.1", | ||
"escape-html": "1.0.3", | ||
"minimatch": "~3.0.3", | ||
"request": "~2.81.0", | ||
"showdown": "~1.6.4", | ||
"strip-json-comments": "~2.0.1", | ||
"xml2js": "~0.4.17", | ||
"yandex-speller": "~2.0.1" | ||
"async": "^2.5.0", | ||
"chalk": "^2.0.1", | ||
"commander": "^2.11.0", | ||
"entities": "^1.1.1", | ||
"escape-html": "^1.0.3", | ||
"eyo-kernel": "^2.2.0", | ||
"glob": "^7.1.2", | ||
"isutf8": "^2.0.1", | ||
"minimatch": "^3.0.4", | ||
"request": "^2.81.0", | ||
"showdown": "^1.7.1", | ||
"strip-json-comments": "^2.0.1", | ||
"xml2js": "^0.4.17", | ||
"yandex-speller": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"chai": "~3.5.0", | ||
"eslint": "~3.17.0", | ||
"chai": "~4.1.0", | ||
"eslint": "~4.3.0", | ||
"istanbul": "~0.4.5", | ||
"jscs": "~3.0.7", | ||
"mocha": "~3.2.0", | ||
"sinon": "~1.17.7" | ||
"mocha": "~3.4.2", | ||
"sinon": "~2.4.1" | ||
}, | ||
@@ -59,0 +60,0 @@ "engines": { |
@@ -118,3 +118,3 @@ yaspeller | ||
#### `--max-requests <value>` | ||
Max count of requests at a time.<br/> | ||
Max count of requests in parallel.<br/> | ||
Default: `2`. | ||
@@ -121,0 +121,0 @@ |
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
71638
27
1908
14
+ Addedglob@^7.1.2
+ Addedajv@6.12.6(transitive)
+ Addedansi-regex@4.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcliui@5.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addedeyo-kernel@2.5.6(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedisutf8@2.1.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.9.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedshowdown@1.9.1(transitive)
+ Addedstring-width@3.1.0(transitive)
+ Addedstrip-ansi@5.2.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@5.1.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyandex-speller@2.1.1(transitive)
+ Addedyargs@14.2.3(transitive)
+ Addedyargs-parser@15.0.3(transitive)
- Removedajv@4.11.8(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedassert-plus@0.2.0(transitive)
- Removedasync@2.1.5(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedboom@2.10.1(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcliui@3.2.0(transitive)
- Removedco@4.6.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcommander@2.9.0(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedeyo-kernel@1.0.7(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedform-data@2.1.4(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedgraceful-readlink@1.0.1(transitive)
- Removedhar-schema@1.0.5(transitive)
- Removedhar-validator@4.2.1(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedisarray@2.0.5(transitive)
- Removedisutf8@2.0.4(transitive)
- Removedjson-stable-stringify@1.1.1(transitive)
- Removedjsonify@0.0.1(transitive)
- Removedlcid@1.0.0(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedminimatch@3.0.8(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedperformance-now@0.2.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedqs@6.4.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedrequest@2.81.0(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedshowdown@1.6.4(transitive)
- Removedsntp@1.0.9(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtough-cookie@2.3.4(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhich-module@1.0.0(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyandex-speller@2.0.1(transitive)
- Removedyargs@6.6.0(transitive)
- Removedyargs-parser@4.2.1(transitive)
Updatedasync@^2.5.0
Updatedchalk@^2.0.1
Updatedcommander@^2.11.0
Updatedentities@^1.1.1
Updatedescape-html@^1.0.3
Updatedeyo-kernel@^2.2.0
Updatedisutf8@^2.0.1
Updatedminimatch@^3.0.4
Updatedrequest@^2.81.0
Updatedshowdown@^1.7.1
Updatedstrip-json-comments@^2.0.1
Updatedxml2js@^0.4.17
Updatedyandex-speller@^2.0.1