strip-ansi
Advanced tools
Comparing version 0.2.1 to 0.2.2
26
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
var fs = require('fs'); | ||
var strip = require('./index'); | ||
var pkg = require('./package.json'); | ||
var strip = require('./'); | ||
var input = process.argv[2]; | ||
if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { | ||
console.log('strip-ansi <input file> > <output file>'); | ||
console.log('or'); | ||
console.log('cat <input file> | strip-ansi > <output file>'); | ||
function help() { | ||
console.log([ | ||
pkg.description, | ||
'', | ||
'Usage', | ||
' $ strip-ansi <input-file> > <output-file>', | ||
' $ cat <input-file> | strip-ansi > <output-file>', | ||
'', | ||
'Example', | ||
' $ strip-ansi unicorn.txt > unicorn-stripped.txt' | ||
].join('\n')); | ||
} | ||
if (process.argv.indexOf('--help') !== -1) { | ||
help(); | ||
return; | ||
} | ||
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { | ||
console.log(require('./package').version); | ||
if (process.argv.indexOf('--version') !== -1) { | ||
console.log(pkg.version); | ||
return; | ||
@@ -17,0 +29,0 @@ } |
'use strict'; | ||
var ansiRegex = require('ansi-regex'); | ||
module.exports = function (str) { | ||
return typeof str === 'string' ? str.replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g, '') : str; | ||
return typeof str === 'string' ? str.replace(ansiRegex, '') : str; | ||
}; |
{ | ||
"name": "strip-ansi", | ||
"version": "0.2.1", | ||
"description": "Strip ANSI escape codes (used for colorizing strings in the terminal)", | ||
"version": "0.2.2", | ||
"description": "Strip ANSI escape codes", | ||
"license": "MIT", | ||
@@ -50,2 +50,5 @@ "bin": { | ||
], | ||
"dependencies": { | ||
"ansi-regex": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -52,0 +55,0 @@ "mocha": "*" |
# strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi) | ||
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) (used for colorizing strings in the terminal) | ||
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) | ||
Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk). | ||
## Install | ||
```bash | ||
```sh | ||
$ npm install --save strip-ansi | ||
@@ -27,16 +25,15 @@ ``` | ||
You can also use it as a CLI app by installing it globally: | ||
```bash | ||
```sh | ||
$ npm install --global strip-ansi | ||
``` | ||
#### Usage | ||
```bash | ||
```sh | ||
$ strip-ansi --help | ||
strip-ansi <input-file> | ||
or | ||
cat <input-file> | strip-ansi | ||
Usage | ||
$ strip-ansi <input-file> > <output-file> | ||
$ cat <input-file> | strip-ansi > <output-file> | ||
Example | ||
$ strip-ansi unicorn.txt > unicorn-stripped.txt | ||
``` | ||
@@ -47,2 +44,2 @@ | ||
[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
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
39
2504
1
44
+ Addedansi-regex@^0.1.0
+ Addedansi-regex@0.1.0(transitive)