Comparing version 3.3.0 to 4.0.0
# Changelog | ||
## 4.0.0 | ||
- Add --init CLI option #77 | ||
- Add --stdin and --stdin-filename CLI options #76 | ||
Before: | ||
`echo "Hello, world!" | yaspeller` | ||
After: | ||
`echo "Hello, world!" | yaspeller --stdin` | ||
or | ||
`echo "Hello, world!" | yaspeller --stdin --stdin-filename hello.txt` | ||
## 3.3.0 | ||
@@ -4,0 +16,0 @@ - Glob patterns for Windows |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const chalk = require('chalk'); | ||
const fs = require('fs'); | ||
const program = require('commander'); | ||
@@ -15,3 +16,2 @@ const programOptions = require('./options'); | ||
const isTTY = process.stdin.isTTY; | ||
const jsonDefault = require('../.yaspellerrc.default.json'); | ||
@@ -22,2 +22,3 @@ | ||
const isStdin = program.stdin; | ||
const jsonConfig = utils.getConfig(program.config); | ||
@@ -61,3 +62,14 @@ const json = Object.assign({}, jsonDefault, jsonConfig); | ||
if (isTTY && !program.args.length) { | ||
if (program.init) { | ||
const yrc = '.yaspellerrc'; | ||
if (fs.existsSync(yrc)) { | ||
console.log(`File ${yrc} has already been created.`); | ||
} else { | ||
fs.writeFileSync(yrc, JSON.stringify(jsonDefault, null, 2)); | ||
console.log(`Successfully created ${yrc} file in ${process.cwd()}`); | ||
} | ||
process.exit(); | ||
} | ||
if (!isStdin && !program.args.length) { | ||
program.help(); | ||
@@ -67,5 +79,5 @@ } | ||
async.series( | ||
isTTY || program.args.length ? | ||
tasks.forResources(program.args, settings) : | ||
tasks.forStdin(settings), | ||
isStdin ? | ||
tasks.forStdin(settings, program.stdinFilename) : | ||
tasks.forResources(program.args, settings), | ||
function() { | ||
@@ -72,0 +84,0 @@ report.onend(); |
@@ -23,2 +23,3 @@ 'use strict'; | ||
.option('-e, --file-extensions <value>', 'set file extensions to search for files in a folder. Example: ".md,.html"', splitByCommas, null) | ||
.option('--init', 'save default config ".yaspellerrc" in current directory') | ||
.option('--dictionary <file>', 'json file for own dictionary', value => splitTrim(value, ':'), []) | ||
@@ -31,6 +32,8 @@ .option('--no-colors', 'clean output without colors') | ||
.option('--ignore-text <regexp>', 'ignore text using RegExp') | ||
.option('--stdin', 'process files on <STDIN>. Default: false') | ||
.option('--stdin-filename <file>', 'specify filename to process STDIN as') | ||
.option('--max-requests <number>', 'max count of requests at a time. Default: 2', parseInt, 0) | ||
.option('--only-errors', 'output only errors') | ||
.option('--debug', 'debug mode') | ||
.option('--check-yo', 'checking the letter Ё (Yo) in words.'); | ||
.option('--check-yo', 'checking the letter Ё (Yo) in words.') | ||
.option('--debug', 'debug mode'); | ||
@@ -37,0 +40,0 @@ this.apiOptions.forEach(function(el) { |
@@ -85,5 +85,6 @@ 'use strict'; | ||
* @param {Object} settings | ||
* @param {string} [filename] | ||
* @return {Array} | ||
*/ | ||
forStdin(settings) { | ||
forStdin(settings, filename) { | ||
return [function(callback) { | ||
@@ -106,3 +107,3 @@ let text = ''; | ||
err ? data : { | ||
resource: 'stdin', | ||
resource: filename || 'stdin', | ||
data: data, | ||
@@ -109,0 +110,0 @@ time: Date.now() - startTime |
@@ -13,3 +13,3 @@ { | ||
"description": "Search tool typos in the text, files and websites", | ||
"version": "3.3.0", | ||
"version": "4.0.0", | ||
"license": "MIT", | ||
@@ -53,7 +53,7 @@ "homepage": "https://github.com/hcodes/yaspeller", | ||
"chai": "~4.1.0", | ||
"eslint": "~4.3.0", | ||
"eslint": "~4.6.1", | ||
"istanbul": "~0.4.5", | ||
"jscs": "~3.0.7", | ||
"mocha": "~3.4.2", | ||
"sinon": "~2.4.1" | ||
"mocha": "~3.5.0", | ||
"sinon": "~3.2.1" | ||
}, | ||
@@ -60,0 +60,0 @@ "engines": { |
@@ -27,6 +27,8 @@ yaspeller | ||
+ `yaspeller README.md` — search typos in the file. | ||
+ `yaspeller "*.md"` — node glob syntax for Windows. | ||
+ `yaspeller -e ".md,.html,.js" ./texts/` — finding typos in files in the folder. | ||
+ `yaspeller https://ru.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%87%D0%B0%D1%82%D0%BA%D0%B0` — search typos in the page. | ||
+ `yaspeller http://bem.info/sitemap.xml` — search typos at the addresses specified in the sitemap.xml. | ||
+ `echo "Hello, world!" | yaspeller` | ||
+ `echo "Hello, world!" | yaspeller --stdin` | ||
+ `echo "Hello, world!" | yaspeller --stdin --stdin-filename hello.txt` | ||
@@ -128,2 +130,8 @@ ### Options | ||
#### `--stdin` | ||
Process files on <STDIN>. Default: false | ||
#### `--stdin-filename <file>` | ||
Specify filename to process STDIN as. Used in reports. | ||
#### `--debug` | ||
@@ -130,0 +138,0 @@ Debug mode. |
Sorry, the diff of this file is not supported yet
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
72831
1923
290
10