Skelleton extended.
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
var fs = require('fs');
|
||||
var strip = require('./index');
|
||||
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>');
|
||||
return;
|
||||
}
|
||||
|
||||
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
|
||||
console.log(require('./package').version);
|
||||
return;
|
||||
}
|
||||
|
||||
if (input) {
|
||||
process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.on('data', function (data) {
|
||||
process.stdout.write(strip(data));
|
||||
});
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
module.exports = function (str) {
|
||||
return typeof str === 'string' ? str.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/g, '') : str;
|
||||
};
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "strip-ansi@~0.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "strip-ansi",
|
||||
"name": "strip-ansi",
|
||||
"rawSpec": "~0.1.0",
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/chalk"
|
||||
]
|
||||
],
|
||||
"_from": "strip-ansi@>=0.1.0 <0.2.0",
|
||||
"_id": "strip-ansi@0.1.1",
|
||||
"_inCache": true,
|
||||
"_location": "/strip-ansi",
|
||||
"_npmUser": {
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.3.15",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "strip-ansi@~0.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "strip-ansi",
|
||||
"name": "strip-ansi",
|
||||
"rawSpec": "~0.1.0",
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/chalk"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz",
|
||||
"_shasum": "39e8a98d044d150660abe4a6808acf70bb7bc991",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "strip-ansi@~0.1.0",
|
||||
"_where": "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/chalk",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"bin": {
|
||||
"strip-ansi": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/strip-ansi/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Strip ANSI escape codes (used for colorizing strings in the terminal)",
|
||||
"devDependencies": {
|
||||
"mocha": "~1.x"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "39e8a98d044d150660abe4a6808acf70bb7bc991",
|
||||
"tarball": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/strip-ansi",
|
||||
"keywords": [
|
||||
"strip",
|
||||
"trim",
|
||||
"remove",
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "strip-ansi",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sindresorhus/strip-ansi.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
# strip-ansi [](http://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)
|
||||
|
||||
Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
Install locally with [npm](https://npmjs.org/package/strip-ansi):
|
||||
|
||||
```
|
||||
npm install --save strip-ansi
|
||||
```
|
||||
|
||||
Or globally if you want to use it as a CLI app:
|
||||
|
||||
```
|
||||
npm install --global strip-ansi
|
||||
```
|
||||
|
||||
You can then use it in your Terminal like:
|
||||
|
||||
```
|
||||
strip-ansi file-with-color-codes
|
||||
```
|
||||
|
||||
Or pipe something to it:
|
||||
|
||||
```
|
||||
ls | strip-ansi
|
||||
```
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var stripAnsi = require('strip-ansi');
|
||||
stripAnsi('\x1b[4mcake\x1b[0m');
|
||||
//=> cake
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user