Skip to content

Commit ed3700b

Browse files
authored
Merge pull request #23 from hcodes/only_safe
Выводить только безопасные замены
2 parents faaa557 + 4a405eb commit ed3700b

File tree

6 files changed

+163
-156
lines changed

6 files changed

+163
-156
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v4.1.0
4+
- Вывод только безопасных замен с помощью CLI-параметра `--only-safe` вместе с `--lint`.
5+
- Обновлены зависимости в package.json.
6+
37
## v4.0.1
48
Обновлены зависимости в package.json.
59

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Options:
3232
-V, --version Output the version number
3333
-l, --lint Search of safe and unsafe replacements
3434
-s, --sort Sort results
35+
--only-safe Output only safe replacements
3536
--stdin Process text provided on <STDIN>
3637
--stdin-filename <file> Specify filename to process STDIN as
3738
--no-colors Clean output without colors

bin/cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ program
1111
.version(require('../package.json').version)
1212
.usage('[options] <file-or-url...>\n\n Restoring the letter “ё” (yo) in russian texts.')
1313
.option('-l, --lint', 'Search of safe and unsafe replacements')
14+
.option('--only-safe', 'Output only safe replacements')
1415
.option('-s, --sort', 'Sort results')
1516
.option('--no-colors', 'Clean output without colors')
1617
.option('--stdin', 'Process text provided on <STDIN>')

bin/utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ module.exports = {
9191
}
9292
}
9393

94-
const notSafeReplacement = notSafeEyo.lint(text, program.sort);
95-
if (notSafeReplacement.length) {
96-
console.log(chalk.red((notSafeReplacement.length ? '\n' : '') + 'Not safe replacements:'));
97-
notSafeReplacement.forEach(printItem.bind(this, 'yellow'));
94+
if (!program.onlySafe) {
95+
const notSafeReplacement = notSafeEyo.lint(text, program.sort);
96+
if (notSafeReplacement.length) {
97+
console.log(chalk.red((notSafeReplacement.length ? '\n' : '') + 'Not safe replacements:'));
98+
notSafeReplacement.forEach(printItem.bind(this, 'yellow'));
99+
}
98100
}
99101
} else {
100102
process.stdout.write(safeEyo.restore(text));

0 commit comments

Comments
 (0)