strip-ansi 0.2.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +24 -16
- package/index.js +1 -1
- package/package.json +5 -5
- package/readme.md +6 -6
package/cli.js
CHANGED
|
@@ -2,38 +2,46 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
var fs = require('fs');
|
|
4
4
|
var pkg = require('./package.json');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var stripAnsi = require('./');
|
|
6
|
+
var argv = process.argv.slice(2);
|
|
7
|
+
var input = argv[0];
|
|
7
8
|
|
|
8
9
|
function help() {
|
|
9
10
|
console.log([
|
|
10
|
-
pkg.description,
|
|
11
11
|
'',
|
|
12
|
-
'
|
|
13
|
-
' $ strip-ansi <input-file> > <output-file>',
|
|
14
|
-
' $ cat <input-file> | strip-ansi > <output-file>',
|
|
12
|
+
' ' + pkg.description,
|
|
15
13
|
'',
|
|
16
|
-
'
|
|
17
|
-
'
|
|
14
|
+
' Usage',
|
|
15
|
+
' strip-ansi <input-file> > <output-file>',
|
|
16
|
+
' cat <input-file> | strip-ansi > <output-file>',
|
|
17
|
+
'',
|
|
18
|
+
' Example',
|
|
19
|
+
' strip-ansi unicorn.txt > unicorn-stripped.txt'
|
|
18
20
|
].join('\n'));
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
function init(data) {
|
|
24
|
+
process.stdout.write(stripAnsi(data));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (argv.indexOf('--help') !== -1) {
|
|
22
28
|
help();
|
|
23
29
|
return;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
if (
|
|
32
|
+
if (argv.indexOf('--version') !== -1) {
|
|
27
33
|
console.log(pkg.version);
|
|
28
34
|
return;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
if (input) {
|
|
32
|
-
|
|
37
|
+
if (!input && process.stdin.isTTY) {
|
|
38
|
+
help();
|
|
33
39
|
return;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
if (input) {
|
|
43
|
+
init(fs.readFileSync(input, 'utf8'));
|
|
44
|
+
} else {
|
|
45
|
+
process.stdin.setEncoding('utf8');
|
|
46
|
+
process.stdin.on('data', init);
|
|
47
|
+
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strip-ansi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Strip ANSI escape codes",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"bin": {
|
|
7
|
-
"strip-ansi": "cli.js"
|
|
8
|
-
},
|
|
9
6
|
"repository": "sindresorhus/strip-ansi",
|
|
10
7
|
"author": {
|
|
11
8
|
"name": "Sindre Sorhus",
|
|
12
9
|
"email": "sindresorhus@gmail.com",
|
|
13
10
|
"url": "http://sindresorhus.com"
|
|
14
11
|
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"strip-ansi": "cli.js"
|
|
14
|
+
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=0.10.0"
|
|
17
17
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"text"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"ansi-regex": "^
|
|
51
|
+
"ansi-regex": "^1.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"mocha": "*"
|
package/readme.md
CHANGED
|
@@ -15,7 +15,7 @@ $ npm install --save strip-ansi
|
|
|
15
15
|
```js
|
|
16
16
|
var stripAnsi = require('strip-ansi');
|
|
17
17
|
|
|
18
|
-
stripAnsi('\
|
|
18
|
+
stripAnsi('\u001b[4mcake\u001b[0m');
|
|
19
19
|
//=> 'cake'
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -29,12 +29,12 @@ $ npm install --global strip-ansi
|
|
|
29
29
|
```sh
|
|
30
30
|
$ strip-ansi --help
|
|
31
31
|
|
|
32
|
-
Usage
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
Usage
|
|
33
|
+
strip-ansi <input-file> > <output-file>
|
|
34
|
+
cat <input-file> | strip-ansi > <output-file>
|
|
35
35
|
|
|
36
|
-
Example
|
|
37
|
-
|
|
36
|
+
Example
|
|
37
|
+
strip-ansi unicorn.txt > unicorn-stripped.txt
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
|