Socket
Socket
Sign inDemoInstall

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 0.7.2 to 0.8.0

20

.yaspellerrc.default.json
{
"excludeFiles": [
".git",
"yaspeller",
"node_modules"
],
"excludeFiles": [],
"fileExtensions": [],
"format": "auto",
"lang": "en,ru",
"fileExtensions": [
"md",
"htm",
"html",
"txt",
"text",
"svg",
"wiki",
"xhtml",
"xml"
]
"lang": "en,ru"
}

67

bin/cli.js

@@ -14,6 +14,6 @@ #!/usr/bin/env node

settings = {},
jsonAtDir = {},
jsonConfig = {},
hasTypos = false,
json = require('../.yaspellerrc.default.json'),
defaultFileExtensions = json.fileExtensions.join(','),
jsonAtDirFilename = './.yaspellerrc';
defaultFileExtensions = json.fileExtensions.join(',');

@@ -100,6 +100,6 @@ function getTypos(data) {

function hasManyErrors(data) {
var hasErrors = false;
var hasErr = false;
data.some(function(el) {
if(el.code === 4) { // ERROR_TOO_MANY_ERRORS
hasErrors = true;
hasErr = true;
return true;

@@ -110,3 +110,3 @@ }

return hasErrors;
return hasErr;
}

@@ -151,6 +151,7 @@

if(textErrors.length) {
hasTypos = true;
console.error(chalk.red('[ERR]') + ' ' + data.resource + time);
console.error(textErrors.join('\n') + '\n');
} else {
program.onlyErrors || console.log(chalk.green('[OK]') + ' ' + data.resource + time);
} else if(!program.onlyErrors) {
console.log(chalk.green('[OK]') + ' ' + data.resource + time);
}

@@ -181,7 +182,8 @@ }

.option('-f, --format <value>', 'formats: plain, html or auto. Default: auto')
.option('-c, --config <path>', 'configuration file path')
.option('--file-extensions <value>', 'set file extensions to search for files in a folder. Default: "' + defaultFileExtensions + '"', splitOnCommas, null)
.option('--dictionary <file>', 'json file for own dictionary')
.option('--no-colors', 'clean output without colors')
.option('--max-requests <value>', 'max count of requests at a time. Default: 2', parseInt, 0)
.option('--report', 'generate html report - ./yaspeller.html')
.option('--max-requests <number>', 'max count of requests at a time. Default: 2', parseInt, 0)
//.option('--report', 'generate html report - ./yaspeller.html')
.option('--only-errors', 'output only errors')

@@ -200,9 +202,10 @@ .option('--debug', 'debug mode');

printDebug('get/check ./yaspellerrc');
if(fs.existsSync(jsonAtDirFilename)) {
printDebug('get/check JSON config');
var jsonConfigFilename = program.config || './.yaspellerrc';
if(fs.existsSync(jsonConfigFilename)) {
try {
jsonAtDir = JSON.parse(fs.readFileSync(jsonAtDirFilename));
printDebug('Using ' + jsonAtDirFilename);
jsonConfig = JSON.parse(fs.readFileSync(jsonConfigFilename));
printDebug('Using config: ' + jsonConfigFilename);
} catch(e) {
console.error(chalk.red('Error parsing ' + jsonAtDirFilename));
console.error(chalk.red('Error parsing ' + jsonConfigFilename));
process.exit(2);

@@ -212,4 +215,4 @@ }

Object.keys(jsonAtDir).forEach(function(key) {
json[key] = jsonAtDir[key];
Object.keys(jsonConfig).forEach(function(key) {
json[key] = jsonConfig[key];
});

@@ -296,11 +299,14 @@

if(fs.existsSync(resource)) {
if(fs.statSync(resource).isDirectory()) {
yaspeller.checkDir(resource, function() {
cb();
}, settings, onResource);
} else {
yaspeller.checkFile(resource, function(err, data) {
onResource(err, data);
cb();
}, settings);
if(!yaspeller.isExcludedFile(resource)) {
if(fs.statSync(resource).isDirectory()) {
yaspeller.checkDir(resource, function() {
cb();
}, settings, onResource);
} else if(yaspeller.getRegExpFileExtensions().test(resource)) {
yaspeller.checkFile(resource, function(err, data) {
onResource(err, data);
cb();
}, settings);
}
}

@@ -316,4 +322,11 @@ } else {

async.series(tasks, function() {
program.onlyErrors || console.log(chalk.magenta('Checking finished: ' + ((+new Date() - startTime) / 1000) + ' sec.'));
if(!program.onlyErrors) {
if(!hasErrors && !hasTypos) {
console.log(chalk.green('No errors.'));
}
console.log(chalk.magenta('Checking finished: ' + ((+new Date() - startTime) / 1000) + ' sec.'));
}
process.exit(hasErrors ? 1 : 0);
});

@@ -10,3 +10,3 @@ /* jshint maxlen: 300 */

printDebug = require('../lib/debug').print,
YASPELLER_API_URL = 'http://speller.yandex.net/services/spellservice.json/checkText',
YASPELLER_API_URL = 'https://speller.yandex.net/services/spellservice.json/checkText',
params = {

@@ -72,5 +72,19 @@ excludeFiles: [],

function isExcludedFile(file) {
for(var i = 0; i < params.excludeFiles.length; i++) {
if(minimatch(file, params.excludeFiles[i])) {
return true;
}
}
return false;
}
function getRegExpFileExtensions() {
return new RegExp('(' + params.fileExtensions.join('|').replace(/\./g, '\\.') + ')$', 'i');
}
function findFiles(dir) {
var res = [],
regExp = new RegExp('\\.(' + params.fileExtensions.join('|') + ')$', 'i'),
regExp = getRegExpFileExtensions(),
isDir = function(dir) {

@@ -83,6 +97,4 @@ return fs.statSync(dir).isDirectory();

var file = pth.join(path, el);
for(var i = 0; i < params.excludeFiles.length; i++) {
if(minimatch(file, params.excludeFiles[i])) {
return;
}
if(isExcludedFile(file)) {
return;
}

@@ -92,3 +104,3 @@

find(file);
} else if(file.search(regExp) !== -1) {
} else if(regExp.test(file)) {
res.push(file);

@@ -179,3 +191,3 @@ }

function splitText(text) {
var MAX_LEN = 10000, // max length of text for Yandex.Speller API
var MAX_LEN = 10000, // Max length of text for Yandex.Speller API
texts = [],

@@ -390,2 +402,4 @@ pos = 0,

},
getRegExpFileExtensions: getRegExpFileExtensions,
isExcludedFile: isExcludedFile,
checkText: checkText,

@@ -392,0 +406,0 @@ checkFile: checkFile,

The MIT License (MIT)
© 2014—2015 Denis Seleznev, <hcodes@yandex.ru>
© 2015 Denis Seleznev, <hcodes@yandex.ru>

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -10,3 +10,3 @@ {

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

@@ -37,3 +37,3 @@ "homepage": "https://github.com/hcodes/yaspeller",

"istanbul": "0.3.x",
"jscs": "1.9.x",
"jscs": "1.10.x",
"jshint": "2.x"

@@ -55,3 +55,10 @@ },

"yaspeller": "./bin/cli.js"
}
},
"files": [
"bin",
"lib",
"index.js",
".yaspellerrc.default.json",
"LICENSE.md"
]
}

@@ -21,3 +21,3 @@ yaspeller

+ `yaspeller README.md` — search typos in the file.
+ `yaspeller ./texts/` — finding typos in files (xml, html, htm, txt, text, svg, md, wiki) in the folder.
+ `yaspeller ./texts/` — finding typos in files (.xml, .html, .htm, .txt, .text, .svg, .md, .wiki) in the folder.
+ `yaspeller http://www.yandex.ru/` — search typos in the page.

@@ -36,5 +36,8 @@ + `yaspeller http://bem.info/sitemap.xml` — search typos at the addresses specified in the sitemap.xml.

#### `-c, --config <path>`
Configuration file path.
#### `--file-extensions <value>`
Set file extensions to search for files in a folder.<br/>
Default: `md,htm,html,txt,text,svg,wiki,xhtml,xml`.
Example: `.md,.htm,.txt`.

@@ -113,5 +116,5 @@ #### `--dictionary <file>`

"fileExtensions": [
"md",
"js",
"css"
".md",
".js",
".css"
],

@@ -118,0 +121,0 @@ "dictionary": [

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