[nodejs-supports-color] Initial import (#1169924)

Ralph Bean ralph at fedoraproject.org
Mon Feb 16 14:35:53 UTC 2015


commit 1a199e49bbd7b89952ba804ce86b0998600a5b63
Author: Ralph Bean <rbean at redhat.com>
Date:   Mon Feb 16 09:24:32 2015 -0500

    Initial import (#1169924)

 .gitignore                 |    1 +
 license                    |   21 ++++++++++
 nodejs-supports-color.spec |   91 ++++++++++++++++++++++++++++++++++++++++++++
 sources                    |    1 +
 test.js                    |   54 ++++++++++++++++++++++++++
 5 files changed, 168 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..1e79400 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/supports-color-1.2.0.tgz
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/nodejs-supports-color.spec b/nodejs-supports-color.spec
new file mode 100644
index 0000000..3bca37d
--- /dev/null
+++ b/nodejs-supports-color.spec
@@ -0,0 +1,91 @@
+# This macro is needed at the start for building on EL6
+%{?nodejs_find_provides_and_requires}
+
+%global enable_tests 1
+
+%global barename supports-color
+
+Name:               nodejs-supports-color
+Version:            1.2.0
+Release:            2%{?dist}
+Summary:            Detect whether a terminal supports color
+
+Group:              Development/Libraries
+License:            MIT
+URL:                https://www.npmjs.org/package/supports-color
+Source0:            http://registry.npmjs.org/%{barename}/-/%{barename}-%{version}.tgz
+
+# The license is MIT, but it is not included in the tarball.
+# I have asked the author before if he would include the license with other
+# projects, and he declined.  I don't want to pester him again...
+# https://github.com/sindresorhus/supports-color/blob/master/license#L12-L13
+#Source1:            https://raw.githubusercontent.com/sindresorhus/supports-color/master/license
+Source1:            license
+
+#Source2:            https://raw.githubusercontent.com/sindresorhus/supports-color/master/test.js
+Source2:            test.js
+
+BuildArch:          noarch
+%if 0%{?fedora} >= 19
+ExclusiveArch:      %{nodejs_arches} noarch
+%else
+ExclusiveArch:      %{ix86} x86_64 %{arm} noarch
+%endif
+
+BuildRequires:      nodejs-packaging >= 6
+
+%if 0%{?enable_tests}
+BuildRequires:      npm(require-uncached)
+BuildRequires:      npm(mocha)
+%endif
+
+
+%description
+Detect whether a terminal supports color
+
+%prep
+%setup -q -n package
+cp %{SOURCE1} .
+cp %{SOURCE2} .
+
+# Remove bundled node_modules if there are any..
+rm -rf node_modules/
+
+%nodejs_fixdep --caret
+
+%build
+# This causes warnings when running the tests
+#%nodejs_symlink_deps --build
+
+%install
+mkdir -p %{buildroot}%{nodejs_sitelib}/supports-color
+cp -pr package.json index.js cli.js \
+    %{buildroot}%{nodejs_sitelib}/supports-color
+
+mkdir -p %{buildroot}/%{_bindir}/
+ln -s %{nodejs_sitelib}/supports-color/cli.js \
+    %{buildroot}/%{_bindir}/supports-color
+
+%nodejs_symlink_deps
+
+%check
+%if 0%{?enable_tests}
+%nodejs_symlink_deps --check
+mocha
+%endif
+
+%files
+%license license
+%doc readme.md
+%{nodejs_sitelib}/supports-color/
+%{_bindir}/supports-color
+
+%changelog
+* Tue Feb 10 2015 Ralph Bean <rbean at redhat.com> - 1.2.0-2
+- Include license from github.
+- Enable tests.
+- Make cli.js into a symlink.
+- Comment out nodejs_symlink_deps --build, as per review.
+
+* Tue Dec 02 2014 Ralph Bean <rbean at redhat.com> - 1.2.0-1
+- Initial packaging for Fedora.
diff --git a/sources b/sources
index e69de29..8de8a4a 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+1c89aad8319c10528a01b56e364f6f68  supports-color-1.2.0.tgz
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..580e8a7
--- /dev/null
+++ b/test.js
@@ -0,0 +1,54 @@
+'use strict';
+var assert = require('assert');
+var requireUncached = require('require-uncached');
+
+beforeEach(function () {
+	process.stdout.isTTY = true;
+	process.argv = [];
+	process.env = {};
+});
+
+it('should return false if not TTY', function () {
+	process.stdout.isTTY = false;
+	assert.equal(requireUncached('./'), false);
+});
+
+it('should return false if --no-color flag is used', function () {
+	process.argv = ['--no-color'];
+	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(requireUncached('./'), true);
+});
+
+it('should return true if --colors flag is used', function () {
+	process.argv = ['--colors'];
+	assert.equal(requireUncached('./'), true);
+});
+
+it('should return true if `COLORTERM` is in env', function () {
+	process.env.COLORTERM = 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);
+});


More information about the scm-commits mailing list