strip-ansi 0.1.0 → 0.2.2
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 +19 -21
- package/index.js +3 -1
- package/package.json +7 -4
- package/readme.md +20 -23
package/cli.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
var fs = require('fs');
|
|
4
|
-
var
|
|
4
|
+
var pkg = require('./package.json');
|
|
5
|
+
var strip = require('./');
|
|
5
6
|
var input = process.argv[2];
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
cb(ret);
|
|
19
|
-
});
|
|
8
|
+
function help() {
|
|
9
|
+
console.log([
|
|
10
|
+
pkg.description,
|
|
11
|
+
'',
|
|
12
|
+
'Usage',
|
|
13
|
+
' $ strip-ansi <input-file> > <output-file>',
|
|
14
|
+
' $ cat <input-file> | strip-ansi > <output-file>',
|
|
15
|
+
'',
|
|
16
|
+
'Example',
|
|
17
|
+
' $ strip-ansi unicorn.txt > unicorn-stripped.txt'
|
|
18
|
+
].join('\n'));
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
if (process.argv.indexOf('
|
|
23
|
-
|
|
24
|
-
console.log('or');
|
|
25
|
-
console.log('cat <input file> | strip-ansi > <output file>');
|
|
21
|
+
if (process.argv.indexOf('--help') !== -1) {
|
|
22
|
+
help();
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
if (process.argv.indexOf('
|
|
30
|
-
console.log(
|
|
26
|
+
if (process.argv.indexOf('--version') !== -1) {
|
|
27
|
+
console.log(pkg.version);
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
30
|
|
|
@@ -36,6 +33,7 @@ if (input) {
|
|
|
36
33
|
return;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
process.stdin.setEncoding('utf8');
|
|
37
|
+
process.stdin.on('data', function (data) {
|
|
40
38
|
process.stdout.write(strip(data));
|
|
41
39
|
});
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strip-ansi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Strip ANSI
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Strip ANSI escape codes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"strip-ansi": "cli.js"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "http://sindresorhus.com"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=0.
|
|
16
|
+
"node": ">=0.10.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "mocha"
|
|
@@ -47,7 +47,10 @@
|
|
|
47
47
|
"command-line",
|
|
48
48
|
"text"
|
|
49
49
|
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"ansi-regex": "^0.1.0"
|
|
52
|
+
},
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"mocha": "
|
|
54
|
+
"mocha": "*"
|
|
52
55
|
}
|
|
53
56
|
}
|
package/readme.md
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
# strip-ansi [](https://travis-ci.org/sindresorhus/strip-ansi)
|
|
2
2
|
|
|
3
|
-
> Strip ANSI
|
|
4
|
-
|
|
5
|
-
Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk).
|
|
3
|
+
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
## Install
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
npm install --save strip-ansi
|
|
8
|
+
```sh
|
|
9
|
+
$ npm install --save strip-ansi
|
|
14
10
|
```
|
|
15
11
|
|
|
16
|
-
Or globally if you want to use it as a CLI app:
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
npm install --global strip-ansi
|
|
20
|
-
```
|
|
13
|
+
## Usage
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
```js
|
|
16
|
+
var stripAnsi = require('strip-ansi');
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
stripAnsi('\x1b[4mcake\x1b[0m');
|
|
19
|
+
//=> 'cake'
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
Or pipe something to it:
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
## CLI
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
$ npm install --global strip-ansi
|
|
32
27
|
```
|
|
33
28
|
|
|
29
|
+
```sh
|
|
30
|
+
$ strip-ansi --help
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
Usage
|
|
33
|
+
$ strip-ansi <input-file> > <output-file>
|
|
34
|
+
$ cat <input-file> | strip-ansi > <output-file>
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stripAnsi('\x1b[4mcake\x1b[0m');
|
|
40
|
-
//=> cake
|
|
36
|
+
Example
|
|
37
|
+
$ strip-ansi unicorn.txt > unicorn-stripped.txt
|
|
41
38
|
```
|
|
42
39
|
|
|
43
40
|
|