[Pkg-javascript-commits] [node-has-ansi] 01/02: Imported Upstream version 1.0.3

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Mar 20 22:35:30 UTC 2015


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

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

commit 75bf6036a8af3c662d869ddd7749f2347642d506
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Mar 20 22:46:51 2015 +0100

    Imported Upstream version 1.0.3
---
 .editorconfig  | 15 ++++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .jshintrc      | 13 ++++++++++++
 .travis.yml    |  6 ++++++
 cli.js         | 45 ++++++++++++++++++++++++++++++++++++++++++
 index.js       |  4 ++++
 license        | 21 ++++++++++++++++++++
 package.json   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 readme.md      | 45 ++++++++++++++++++++++++++++++++++++++++++
 test.js        | 28 ++++++++++++++++++++++++++
 11 files changed, 241 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..86c8f59
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+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..804f8af
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,13 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"camelcase": true,
+	"curly": true,
+	"immed": true,
+	"newcap": true,
+	"noarg": true,
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+  - 'iojs'
+  - '0.12'
+  - '0.10'
diff --git a/cli.js b/cli.js
new file mode 100755
index 0000000..0386a82
--- /dev/null
+++ b/cli.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env node
+'use strict';
+var stdin = require('get-stdin');
+var pkg = require('./package.json');
+var hasAnsi = require('./');
+var argv = process.argv.slice(2);
+var input = argv[0];
+
+function help() {
+	console.log([
+		'',
+		'  ' + pkg.description,
+		'',
+		'  Usage',
+		'    has-ansi <string>',
+		'    echo <string> | has-ansi',
+		'',
+		'  Exits with code 0 if input has ANSI escape codes and 1 if not'
+	].join('\n'));
+}
+
+function init(data) {
+	process.exit(hasAnsi(data) ? 0 : 1);
+}
+
+if (argv.indexOf('--help') !== -1) {
+	help();
+	return;
+}
+
+if (argv.indexOf('--version') !== -1) {
+	console.log(pkg.version);
+	return;
+}
+
+if (process.stdin.isTTY) {
+	if (!input) {
+		help();
+		return;
+	}
+
+	init(input);
+} else {
+	stdin(init);
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..98fae06
--- /dev/null
+++ b/index.js
@@ -0,0 +1,4 @@
+'use strict';
+var ansiRegex = require('ansi-regex');
+var re = new RegExp(ansiRegex().source); // remove the `g` flag
+module.exports = re.test.bind(re);
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..5bc942d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,62 @@
+{
+  "name": "has-ansi",
+  "version": "1.0.3",
+  "description": "Check if a string has ANSI escape codes",
+  "license": "MIT",
+  "repository": "sindresorhus/has-ansi",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "http://sindresorhus.com"
+  },
+  "maintainers": [
+    "Sindre Sorhus <sindresorhus at gmail.com> (http://sindresorhus.com)",
+    "Joshua Appelman <jappelman at xebia.com> (http://jbnicolai.com)"
+  ],
+  "bin": {
+    "has-ansi": "cli.js"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "files": [
+    "index.js",
+    "cli.js"
+  ],
+  "keywords": [
+    "cli",
+    "bin",
+    "ansi",
+    "styles",
+    "color",
+    "colour",
+    "colors",
+    "terminal",
+    "console",
+    "string",
+    "tty",
+    "escape",
+    "shell",
+    "xterm",
+    "command-line",
+    "text",
+    "regex",
+    "regexp",
+    "re",
+    "match",
+    "test",
+    "find",
+    "pattern",
+    "has"
+  ],
+  "dependencies": {
+    "ansi-regex": "^1.1.0",
+    "get-stdin": "^4.0.1"
+  },
+  "devDependencies": {
+    "mocha": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..0fa149a
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,45 @@
+# has-ansi [![Build Status](https://travis-ci.org/sindresorhus/has-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/has-ansi)
+
+> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
+
+
+## Install
+
+```sh
+$ npm install --save has-ansi
+```
+
+
+## Usage
+
+```js
+var hasAnsi = require('has-ansi');
+
+hasAnsi('\u001b[4mcake\u001b[0m');
+//=> true
+
+hasAnsi('cake');
+//=> false
+```
+
+
+## CLI
+
+```sh
+$ npm install --global has-ansi
+```
+
+```
+$ has-ansi --help
+
+  Usage
+    has-ansi <string>
+    echo <string> | has-ansi
+
+  Exits with code 0 if input has ANSI escape codes and 1 if not
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..f9e2f47
--- /dev/null
+++ b/test.js
@@ -0,0 +1,28 @@
+'use strict';
+var assert = require('assert');
+var childProcess = require('child_process');
+var hasAnsi = require('./');
+
+it('should check if a string has ANSI escape codes', function () {
+	assert(hasAnsi('foo\u001b[4mcake\u001b[0m'));
+	assert(!hasAnsi('cake'));
+});
+
+describe('the cli', function () {
+
+	it('should exit with 0 if called with stdin containing ANSI escape codes', function (done) {
+		var cli = childProcess.exec('echo -e "foo\u001b[4mcake\u001b[0m" | ./cli.js');
+		cli.on('exit', function (code) {
+			assert(code === 0);
+			done()
+		});
+	});
+
+	it('should exit with 1 if called with stdin containing ANSI escape codes', function (done) {
+		var cli = childProcess.exec('echo -e "boring plain old string" | ./cli.js');
+		cli.on('exit', function (code) {
+			assert(code === 1);
+			done()
+		});
+	});
+});

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



More information about the Pkg-javascript-commits mailing list