[Pkg-javascript-commits] [node-strip-ansi] 01/08: Imported Upstream version 2.0.1

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Mar 20 23:38:06 UTC 2015


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

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

commit 883d6765f470baea693a7607e007b001a7b3f175
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Mar 21 00:31:42 2015 +0100

    Imported Upstream version 2.0.1
---
 .editorconfig |  1 -
 .gitignore    |  1 +
 .jshintrc     |  3 ---
 cli.js        | 40 ++++++++++++++++++++++++----------------
 package.json  | 10 +++++-----
 readme.md     | 12 ++++++------
 test.js       | 10 ++++++++++
 7 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 8311fe1..86c8f59 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,4 +1,3 @@
-# editorconfig.org
 root = true
 
 [*]
diff --git a/.gitignore b/.gitignore
index 3c3629e..163ac7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 node_modules
+colored.example.txt
diff --git a/.jshintrc b/.jshintrc
index c511975..804f8af 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -4,12 +4,9 @@
 	"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/cli.js b/cli.js
index 602ae00..b83f63b 100755
--- a/cli.js
+++ b/cli.js
@@ -2,38 +2,46 @@
 'use strict';
 var fs = require('fs');
 var pkg = require('./package.json');
-var strip = require('./');
-var input = process.argv[2];
+var stripAnsi = require('./');
+var argv = process.argv.slice(2);
+var input = argv[0];
 
 function help() {
 	console.log([
-		pkg.description,
 		'',
-		'Usage',
-		'  $ strip-ansi <input-file> > <output-file>',
-		'  $ cat <input-file> | strip-ansi > <output-file>',
+		'  ' + pkg.description,
 		'',
-		'Example',
-		'  $ strip-ansi unicorn.txt > unicorn-stripped.txt'
+		'  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) {
+function init(data) {
+	process.stdout.write(stripAnsi(data));
+}
+
+if (argv.indexOf('--help') !== -1) {
 	help();
 	return;
 }
 
-if (process.argv.indexOf('--version') !== -1) {
+if (argv.indexOf('--version') !== -1) {
 	console.log(pkg.version);
 	return;
 }
 
-if (input) {
-	process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
+if (!input && process.stdin.isTTY) {
+	help();
 	return;
 }
 
-process.stdin.setEncoding('utf8');
-process.stdin.on('data', function (data) {
-	process.stdout.write(strip(data));
-});
+if (input) {
+	init(fs.readFileSync(input, 'utf8'));
+} else {
+	process.stdin.setEncoding('utf8');
+	process.stdin.on('data', init);
+}
diff --git a/package.json b/package.json
index 3bacc67..554776a 100644
--- a/package.json
+++ b/package.json
@@ -1,17 +1,17 @@
 {
   "name": "strip-ansi",
-  "version": "0.3.0",
+  "version": "2.0.1",
   "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"
   },
+  "bin": {
+    "strip-ansi": "cli.js"
+  },
   "engines": {
     "node": ">=0.10.0"
   },
@@ -48,7 +48,7 @@
     "text"
   ],
   "dependencies": {
-    "ansi-regex": "^0.2.1"
+    "ansi-regex": "^1.0.0"
   },
   "devDependencies": {
     "mocha": "*"
diff --git a/readme.md b/readme.md
index 5477079..53ec264 100644
--- a/readme.md
+++ b/readme.md
@@ -15,7 +15,7 @@ $ npm install --save strip-ansi
 ```js
 var stripAnsi = require('strip-ansi');
 
-stripAnsi('\x1b[4mcake\x1b[0m');
+stripAnsi('\u001b[4mcake\u001b[0m');
 //=> 'cake'
 ```
 
@@ -29,12 +29,12 @@ $ npm install --global strip-ansi
 ```sh
 $ strip-ansi --help
 
-Usage
-  $ strip-ansi <input-file> > <output-file>
-  $ cat <input-file> | strip-ansi > <output-file>
+  Usage
+    strip-ansi <input-file> > <output-file>
+    cat <input-file> | strip-ansi > <output-file>
 
-Example
-  $ strip-ansi unicorn.txt > unicorn-stripped.txt
+  Example
+    strip-ansi unicorn.txt > unicorn-stripped.txt
 ```
 
 
diff --git a/test.js b/test.js
index f7f456e..ed45e3a 100644
--- a/test.js
+++ b/test.js
@@ -21,3 +21,13 @@ it('should strip color with CLI', function (cb) {
 		cb();
 	});
 });
+
+it('should strip color from file with CLI', function (cb) {
+	exec('echo "\u001b[0m\u001b[4m\u001b[42m\u001b[31mfoo\u001b[39m\u001b[49m\u001b[24mfoo\u001b[0m" > colored.example.txt', function (err, stdout) {
+    if (err) cb(err);
+    exec('./cli.js colored.example.txt', function (err, stdout) {
+      assert.equal(stdout, 'foofoo\n');
+      cb(err);
+    });
+  })
+});

-- 
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