Skip to content

Commit ddea553

Browse files
authored
Merge pull request #18 from hcodes/update_deps
v4
2 parents 66504cd + 220ca1f commit ddea553

File tree

7 files changed

+896
-574
lines changed

7 files changed

+896
-574
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"no-console": [0]
99
},
1010
"env": {
11+
"es6": true,
1112
"node": true,
1213
"mocha": true
1314
},

.jscsrc

Lines changed: 0 additions & 33 deletions
This file was deleted.

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.0.0
4+
- Теперь для работы с STDIN необходимо явно указывать опцию `--stdin`.
5+
- Обновлены зависимости в package.json.
6+
37
## v3.1.1
48
- Обновлены зависимости в package.json.
59

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ Usage: eyo [options] <file-or-url...>
2828
Restoring the letter «ё» (yo) in russian texts.
2929
3030
Options:
31-
-h, --help output usage information
32-
-V, --version output the version number
33-
-l, --lint Search of safe and unsafe replacements
34-
-s, --sort Sort results
35-
--no-colors Clean output without colors
31+
-h, --help Output usage information
32+
-V, --version Output the version number
33+
-l, --lint Search of safe and unsafe replacements
34+
-s, --sort Sort results
35+
--stdin Process text provided on <STDIN>
36+
--stdin-filename <file> Specify filename to process STDIN as
37+
--no-colors Clean output without colors
3638
```
3739

3840
### Примеры использования
3941
`eyo file.txt > file.out.txt` — безопасная замена «е» на «ё» в файле.<br/>
4042
`eyo https://example.com/index.html > file.out.html` — безопасная замена «е» на «ё» на странице сайта.
4143

42-
`cat file1.txt file2.txt file3.txt | eyo`
43-
4444
`eyo --lint file1.txt file2.txt` — вывод слов для файлов, где необходима или возможна замена.<br/>
4545
`eyo --lint http://habrahabr.ru` — вывод слов для страницы сайта, где необходима или возможна замена.
4646

47+
`cat file1.txt file2.txt file3.txt | eyo --stdin > output.txt`<br/>
48+
`cat file1.txt | eyo --stdin --stdin-filename file1.txt`
49+
4750
## Node.js
4851

4952
Используйте отдельный пакет [`eyo-kernel`](https://www.npmjs.com/package/eyo-kernel) без зависимостей.

bin/cli.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict';
44

5-
const async = require('async');
65
const chalk = require('chalk');
76
const exit = require('exit');
87
const program = require('commander');
@@ -14,30 +13,17 @@ program
1413
.option('-l, --lint', 'Search of safe and unsafe replacements')
1514
.option('-s, --sort', 'Sort results')
1615
.option('--no-colors', 'Clean output without colors')
16+
.option('--stdin', 'Process text provided on <STDIN>')
17+
.option('--stdin-filename <file>', 'Specify filename to process STDIN as')
1718
.parse(process.argv);
1819

1920
chalk.enabled = program.colors;
2021

21-
if (process.stdin.isTTY && !program.args.length) {
22+
if (!program.stdin && !program.args.length) {
2223
program.help();
2324
}
2425

25-
if (process.stdin.isTTY) {
26-
const tasks = [];
27-
program.args.forEach(function(resource) {
28-
tasks.push(function(callback) {
29-
if (resource.search(/^https?:/) !== -1) {
30-
utils._processUrl(resource, callback);
31-
} else {
32-
utils._processFile(resource, callback);
33-
}
34-
});
35-
});
36-
37-
async.series(tasks, function() {
38-
exit(process.exitCode);
39-
});
40-
} else {
26+
if (program.stdin) {
4127
let text = '';
4228

4329
process.stdin
@@ -49,7 +35,19 @@ if (process.stdin.isTTY) {
4935
}
5036
})
5137
.on('end', function() {
52-
utils._processText(text, 'stdin');
38+
utils._processText(text, program.stdinFilename || 'stdin');
5339
exit(process.exitCode);
5440
});
41+
} else {
42+
Promise.all(program.args.map(resource => {
43+
return new Promise(resolve => {
44+
if (resource.search(/^https?:/) !== -1) {
45+
utils._processUrl(resource, resolve);
46+
} else {
47+
utils._processFile(resource, resolve);
48+
}
49+
});
50+
})).then(() => {
51+
exit(process.exitCode);
52+
});
5553
}

0 commit comments

Comments
 (0)