[Pkg-javascript-commits] [node-strip-ansi] 01/02: Imported Upstream version 0.3.0

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Mon Jun 30 14:34:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-strip-ansi.

commit 8595b347c8a4ebf603c58f2fb45a915a449ca750
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Mon Jun 30 14:25:57 2014 +0000

    Imported Upstream version 0.3.0
---
 .editorconfig  | 16 ++++++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .jshintrc      | 16 ++++++++++++++++
 .travis.yml    |  3 +++
 cli.js         | 39 +++++++++++++++++++++++++++++++++++++++
 index.js       |  6 ++++++
 license        | 21 +++++++++++++++++++++
 package.json   | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 readme.md      | 43 +++++++++++++++++++++++++++++++++++++++++++
 test.js        | 23 +++++++++++++++++++++++
 11 files changed, 225 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8311fe1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[package.json]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..c511975
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,16 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"camelcase": true,
+	"curly": true,
+	"eqeqeq": true,
+	"immed": true,
+	"indent": 4,
+	"newcap": true,
+	"noarg": true,
+	"quotmark": "single",
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..244b7e8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+  - '0.10'
diff --git a/cli.js b/cli.js
new file mode 100755
index 0000000..602ae00
--- /dev/null
+++ b/cli.js
@@ -0,0 +1,39 @@
+#!/usr/bin/env node
+'use strict';
+var fs = require('fs');
+var pkg = require('./package.json');
+var strip = require('./');
+var input = process.argv[2];
+
+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('--version') !== -1) {
+	console.log(pkg.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));
+});
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..099480f
--- /dev/null
+++ b/index.js
@@ -0,0 +1,6 @@
+'use strict';
+var ansiRegex = require('ansi-regex')();
+
+module.exports = function (str) {
+	return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..3bacc67
--- /dev/null
+++ b/package.json
@@ -0,0 +1,56 @@
+{
+  "name": "strip-ansi",
+  "version": "0.3.0",
+  "description": "Strip ANSI escape codes",
+  "license": "MIT",
+  "bin": {
+    "strip-ansi": "cli.js"
+  },
+  "repository": "sindresorhus/strip-ansi",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "http://sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "files": [
+    "index.js",
+    "cli.js"
+  ],
+  "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"
+  ],
+  "dependencies": {
+    "ansi-regex": "^0.2.1"
+  },
+  "devDependencies": {
+    "mocha": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..5477079
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,43 @@
+# 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)
+
+
+## Install
+
+```sh
+$ npm install --save strip-ansi
+```
+
+
+## Usage
+
+```js
+var stripAnsi = require('strip-ansi');
+
+stripAnsi('\x1b[4mcake\x1b[0m');
+//=> 'cake'
+```
+
+
+## CLI
+
+```sh
+$ npm install --global strip-ansi
+```
+
+```sh
+$ strip-ansi --help
+
+Usage
+  $ strip-ansi <input-file> > <output-file>
+  $ cat <input-file> | strip-ansi > <output-file>
+
+Example
+  $ strip-ansi unicorn.txt > unicorn-stripped.txt
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..f7f456e
--- /dev/null
+++ b/test.js
@@ -0,0 +1,23 @@
+'use strict';
+var assert = require('assert');
+var exec = require('child_process').exec;
+var strip = require('./');
+
+it('should strip color from string', function () {
+	assert.equal(strip('\u001b[0m\u001b[4m\u001b[42m\u001b[31mfoo\u001b[39m\u001b[49m\u001b[24mfoo\u001b[0m'), 'foofoo');
+});
+
+it('should strip color from ls command', function () {
+    assert.equal(strip('\u001b[00;38;5;244m\u001b[m\u001b[00;38;5;33mfoo\u001b[0m'), 'foo');
+});
+
+it('should strip reset;setfg;setbg;italics;strike;underline sequence from string', function () {
+	assert.equal(strip('\x1b[0;33;49;3;9;4mbar\x1b[0m'), 'bar');
+});
+
+it('should strip color with CLI', function (cb) {
+	exec('echo "\u001b[0m\u001b[4m\u001b[42m\u001b[31mfoo\u001b[39m\u001b[49m\u001b[24mfoo\u001b[0m" | ./cli.js', function (err, stdout) {
+		assert.equal(stdout, 'foofoo\n');
+		cb();
+	});
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-strip-ansi.git



More information about the Pkg-javascript-commits mailing list