[Pkg-javascript-commits] [node-supports-color] 01/03: Imported Upstream version 1.3.1

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Mar 20 23:56:46 UTC 2015


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

sebastic pushed a commit to branch master
in repository node-supports-color.

commit 4f8e673915d78fc64404f9362d8a7fa0f44b9dde
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Mar 21 00:46:05 2015 +0100

    Imported Upstream version 1.3.1
---
 .editorconfig |  1 -
 .travis.yml   |  6 ++++++
 cli.js        | 15 ++++++++-------
 index.js      | 15 +++++++++++++--
 package.json  | 19 ++++++++++++-------
 readme.md     | 14 ++++++++------
 test.js       | 46 ++++++++++++++++++++++++++++++++++++++++------
 7 files changed, 87 insertions(+), 29 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/.travis.yml b/.travis.yml
index 244b7e8..ccde138 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,9 @@
+sudo: false
 language: node_js
 node_js:
+  - 'iojs'
+  - '0.12'
   - '0.10'
+  - '0.8'
+before_install:
+  - npm install -g npm
diff --git a/cli.js b/cli.js
index 0617971..e746987 100755
--- a/cli.js
+++ b/cli.js
@@ -2,25 +2,26 @@
 'use strict';
 var pkg = require('./package.json');
 var supportsColor = require('./');
-var input = process.argv[2];
+var argv = process.argv.slice(2);
 
 function help() {
 	console.log([
-		pkg.description,
 		'',
-		'Usage',
-		'  $ supports-color',
+		'  ' + pkg.description,
 		'',
-		'Exits with code 0 if color is supported and 1 if not'
+		'  Usage',
+		'    supports-color',
+		'',
+		'  Exits with code 0 if color is supported and 1 if not'
 	].join('\n'));
 }
 
-if (!input || process.argv.indexOf('--help') !== -1) {
+if (argv.indexOf('--help') !== -1) {
 	help();
 	return;
 }
 
-if (process.argv.indexOf('--version') !== -1) {
+if (argv.indexOf('--version') !== -1) {
 	console.log(pkg.version);
 	return;
 }
diff --git a/index.js b/index.js
index 092d0ba..a171964 100644
--- a/index.js
+++ b/index.js
@@ -1,10 +1,21 @@
 'use strict';
+var argv = process.argv;
+
 module.exports = (function () {
-	if (process.argv.indexOf('--no-color') !== -1) {
+	if ('FORCE_COLOR' in process.env) {
+		return true;
+	}
+
+	if (argv.indexOf('--no-color') !== -1 ||
+		argv.indexOf('--no-colors') !== -1 ||
+		argv.indexOf('--color=false') !== -1) {
 		return false;
 	}
 
-	if (process.argv.indexOf('--color') !== -1) {
+	if (argv.indexOf('--color') !== -1 ||
+		argv.indexOf('--colors') !== -1 ||
+		argv.indexOf('--color=true') !== -1 ||
+		argv.indexOf('--color=always') !== -1) {
 		return true;
 	}
 
diff --git a/package.json b/package.json
index 02b0197..7c808ea 100644
--- a/package.json
+++ b/package.json
@@ -1,19 +1,23 @@
 {
   "name": "supports-color",
-  "version": "0.2.0",
+  "version": "1.3.1",
   "description": "Detect whether a terminal supports color",
   "license": "MIT",
   "repository": "sindresorhus/supports-color",
-  "bin": {
-    "supports-color": "cli.js"
-  },
   "author": {
     "name": "Sindre Sorhus",
     "email": "sindresorhus at gmail.com",
-    "url": "http://sindresorhus.com"
+    "url": "sindresorhus.com"
+  },
+  "maintainers": [
+    "Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)",
+    "Joshua Appelman <jappelman at xebia.com> (jbnicolai.com)"
+  ],
+  "bin": {
+    "supports-color": "cli.js"
   },
   "engines": {
-    "node": ">=0.10.0"
+    "node": ">=0.8.0"
   },
   "scripts": {
     "test": "mocha"
@@ -45,6 +49,7 @@
     "detect"
   ],
   "devDependencies": {
-    "mocha": "*"
+    "mocha": "*",
+    "require-uncached": "^1.0.2"
   }
 }
diff --git a/readme.md b/readme.md
index 7f07e5f..fe6016f 100644
--- a/readme.md
+++ b/readme.md
@@ -5,7 +5,7 @@
 
 ## Install
 
-```sh
+```
 $ npm install --save supports-color
 ```
 
@@ -22,20 +22,22 @@ if (supportsColor) {
 
 It obeys the `--color` and `--no-color` CLI flags.
 
+For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
+
 
 ## CLI
 
-```sh
+```
 $ npm install --global supports-color
 ```
 
-```sh
+```
 $ supports-color --help
 
-Usage
-  $ supports-color
+  Usage
+    supports-color
 
-# Exits with code 0 if color is supported and 1 if not
+  Exits with code 0 if color is supported and 1 if not
 ```
 
 
diff --git a/test.js b/test.js
index 4c5c1e8..ec6ad4b 100644
--- a/test.js
+++ b/test.js
@@ -1,30 +1,64 @@
 'use strict';
 var assert = require('assert');
+var requireUncached = require('require-uncached');
 
 beforeEach(function () {
-	// clear the cache of the tested module
-	delete require.cache[require.resolve('./')];
 	process.stdout.isTTY = true;
 	process.argv = [];
 	process.env = {};
 });
 
+it('should return true if `FORCE_COLOR` is in env', function () {
+	process.env.FORCE_COLOR = true;
+	assert.equal(requireUncached('./'), true);
+});
+
 it('should return false if not TTY', function () {
 	process.stdout.isTTY = false;
-	assert.equal(require('./'), false);
+	assert.equal(requireUncached('./'), false);
 });
 
 it('should return false if --no-color flag is used', function () {
 	process.argv = ['--no-color'];
-	assert.equal(require('./'), false);
+	assert.equal(requireUncached('./'), false);
+});
+
+it('should return false if --no-colors flag is used', function () {
+	process.argv = ['--no-colors'];
+	assert.equal(requireUncached('./'), false);
 });
 
 it('should return true if --color flag is used', function () {
 	process.argv = ['--color'];
-	assert.equal(require('./'), true);
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should return true if --colors flag is used', function () {
+	process.argv = ['--colors'];
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should return false if `UPSTART_JOB` is in env', function () {
+	process.env.UPSTART_JOB = true;
+	assert.equal(requireUncached('./'), false);
 });
 
 it('should return true if `COLORTERM` is in env', function () {
 	process.env.COLORTERM = true;
-	assert.equal(require('./'), true);
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should support `--color=true` flag', function () {
+	process.argv = ['--color=true'];
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should support `--color=always` flag', function () {
+	process.argv = ['--color=always'];
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should support `--color=false` flag', function () {
+	process.argv = ['--color=false'];
+	assert.equal(requireUncached('./'), false);
 });

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



More information about the Pkg-javascript-commits mailing list