Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yaspeller

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaspeller - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

lib/tasks.js

4

CHANGELOG.md
# Changelog
## 2.8.0
- Added support for stdin
- Updated deps in package.json
## 2.7.0

@@ -4,0 +8,0 @@ - Separate module for Yandex.Speller API

105

lib/cli.js
'use strict';
var fs = require('fs'),
async = require('async'),
var async = require('async'),
chalk = require('chalk'),
program = require('commander'),
pth = require('path'),
programOptions = require('./options'),

@@ -12,23 +10,14 @@ debug = require('./debug'),

report = require('./report'),
tasks = require('./tasks'),
utils = require('./utils'),
yaspeller = require('./yaspeller'),
_ = require('lodash'),
exitCodes = require('./exit-codes'),
exitCode = 0,
json,
jsonConfig,
jsonDefault = require('../.yaspellerrc.default.json'),
dictionary = [],
settings = {};
programOptions.set({
ignoreTags: jsonDefault.ignoreTags.join(',')
});
programOptions.set({ignoreTags: jsonDefault.ignoreTags.join(',')});
program.parse(process.argv);
if(!program.args.length) {
program.help();
}
jsonConfig = utils.getConfig(program.config);

@@ -59,80 +48,18 @@

dictionary = dict.getDictionary(program.dictionary, json.dictionary);
dict.set(program.dictionary, json.dictionary);
var tasks = [],
hasData = function(err, data) {
return !err && data && Array.isArray(data.data) && data.data.length;
},
onResource = function(err, data) {
if(hasData(err, data)) {
data.data = dict.removeDictWords(data.data, dictionary);
data.data = yaspeller.removeDuplicates(data.data);
}
if(!exitCode && hasData(err, data)) {
exitCode = exitCodes.HAS_TYPOS;
}
if(err) {
exitCode = exitCodes.ERROR_LOADING;
}
report.oneach(err, data);
};
report.addReports(program.report || json.report);
program.args.forEach(function(resource) {
tasks.push(function(cb) {
var subTasks = [];
if(utils.isUrl(resource)) {
if(utils.isSitemap(resource)) {
yaspeller.checkSitemap(resource, function() {
cb();
}, settings, onResource);
} else {
yaspeller.checkUrl(resource, function(err, data) {
onResource(err, data);
cb();
}, settings);
}
} 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) {
onResource(err, data);
subcb();
}, settings);
});
});
if(process.stdin.isTTY && !program.args.length) {
program.help();
}
async.parallelLimit(subTasks, settings.maxRequests, function() {
cb();
});
} else {
var file = pth.resolve(resource);
if(utils.isExcludedFile(file, settings.excludeFiles)) {
cb();
} else {
yaspeller.checkFile(file, function(err, data) {
onResource(err, data);
cb();
}, settings);
}
}
} else {
onResource(true, Error(resource + ': is not exists'));
cb();
}
}
});
});
async.series(tasks, function() {
report.onend();
process.exit(exitCode);
});
async.series(
process.stdin.isTTY ?
tasks.forResources(program.args, settings) :
tasks.forStdin(settings),
function() {
report.onend();
process.exit();
}
);

@@ -14,9 +14,8 @@ var chalk = require('chalk'),

/**
* Get dictionary.
* Set dictionary.
*
* @param {Array} files
* @param {Array} configDictionary - Dictionary from .yaspellerrc
* @return {Array}
*/
getDictionary: function(files, configDictionary) {
set: function(files, configDictionary) {
var result = [],

@@ -49,5 +48,14 @@ count = 0,

return this.prepareDictionary(result);
this._dict = this.prepareDictionary(result);
},
/**
* Get dictionary.
*
* @return {Array}
*/
get: function() {
return this._dict;
},
_dict: [],
/**
* Load dictionary.

@@ -121,7 +129,7 @@ *

* @param {Object[]} data - Array of typos.
* @param {string[]|RegExp[]} dictionary
* @return {Object[]}
*/
removeDictWords: function(data, dictionary) {
var result = [];
removeDictWords: function(data) {
var result = [],
dictionary = this.get();

@@ -128,0 +136,0 @@ data.forEach(function(typo) {

@@ -13,3 +13,3 @@ {

"description": "Search tool typos in the text, files and websites",
"version": "2.7.0",
"version": "2.8.0",
"license": "MIT",

@@ -41,7 +41,7 @@ "homepage": "https://github.com/hcodes/yaspeller",

"entities": "~1.1.1",
"isutf8": "~1.0.11",
"lodash": "^4.12.0",
"isutf8": "~2.0.0",
"lodash": "^4.13.0",
"minimatch": "~3.0.0",
"request": "^2.72.0",
"showdown": "~1.4.0",
"showdown": "~1.4.1",
"strip-json-comments": "~2.0.1",

@@ -54,5 +54,5 @@ "xml2js": "~0.4.16",

"istanbul": "~0.4.3",
"jscs": "~3.0.3",
"jscs": "~3.0.4",
"jshint": "~2.9.2",
"mocha": "~2.4.5",
"mocha": "~2.5.3",
"sinon": "^1.17.4"

@@ -59,0 +59,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc