diff --git a/.gitignore b/.gitignore index 1e79400..a4a855d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /supports-color-1.2.0.tgz +/supports-color-4.4.0.tgz diff --git a/license b/license deleted file mode 100644 index 654d0bf..0000000 --- a/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (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 index 1da191b..1d09988 100644 --- a/nodejs-supports-color.spec +++ b/nodejs-supports-color.spec @@ -1,29 +1,24 @@ # This macro is needed at the start for building on EL6 %{?nodejs_find_provides_and_requires} -%global enable_tests 1 - %global barename supports-color +%global enable_tests 0 +# tests disabled until such time as 'ava' is packaged in Fedora + Name: nodejs-supports-color -Version: 1.2.0 -Release: 6%{?dist} +Version: 4.4.0 +Release: 1%{?dist} Summary: Detect whether a terminal supports color Group: Development/Libraries License: MIT -URL: https://www.npmjs.org/package/supports-color +URL: https://github.com/chalk/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 +# 4.4.0 release hasn't been tagged in github yet +#Source1: https://raw.githubusercontent.com/chalk/supports-color/v%{version}/test.js +Source1: https://raw.githubusercontent.com/chalk/supports-color/master/test.js BuildArch: noarch %if 0%{?fedora} >= 19 @@ -37,6 +32,7 @@ BuildRequires: nodejs-packaging >= 6 %if 0%{?enable_tests} BuildRequires: npm(require-uncached) BuildRequires: npm(mocha) +BuildRequires: npm(has-flag) %endif @@ -46,7 +42,6 @@ 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/ @@ -59,7 +54,7 @@ rm -rf node_modules/ %install mkdir -p %{buildroot}%{nodejs_sitelib}/supports-color -cp -pr package.json index.js cli.js \ +cp -pr package.json *.js \ %{buildroot}%{nodejs_sitelib}/supports-color mkdir -p %{buildroot}/%{_bindir}/ @@ -69,18 +64,25 @@ ln -s %{nodejs_sitelib}/supports-color/cli.js \ %nodejs_symlink_deps %check -%if 0%{?enable_tests} %nodejs_symlink_deps --check -mocha +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" %endif %files +%{!?_licensedir:%global license %doc} %license license %doc readme.md %{nodejs_sitelib}/supports-color/ %{_bindir}/supports-color %changelog +* Wed Sep 20 2017 Jared Smith - 4.4.0-1 +- Update to upstream 4.4.0 release + * Thu Jul 27 2017 Fedora Release Engineering - 1.2.0-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild diff --git a/sources b/sources index 8de8a4a..13df0d2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1c89aad8319c10528a01b56e364f6f68 supports-color-1.2.0.tgz +SHA512 (supports-color-4.4.0.tgz) = aca0b7f83c975a02b464b2b0991b2b9321d56408cd91fcde7a1b8559d18672a1834d9147ef7f911fa4bf443000c65f46bac4a365251660b993f4de69cd714e5d diff --git a/test.js b/test.js index 580e8a7..eb62c2a 100644 --- a/test.js +++ b/test.js @@ -1,54 +1,291 @@ -'use strict'; -var assert = require('assert'); -var requireUncached = require('require-uncached'); +import os from 'os'; +import {serial as test} from 'ava'; +import importFresh from 'import-fresh'; -beforeEach(function () { +test.beforeEach(() => { + Object.defineProperty(process, 'platform', { + value: 'linux' + }); process.stdout.isTTY = true; process.argv = []; process.env = {}; }); -it('should return false if not TTY', function () { +test('return true if `FORCE_COLOR` is in env', t => { + process.env.FORCE_COLOR = true; + const result = importFresh('.'); + t.truthy(result); + t.is(result.level, 1); +}); + +test('return true if `FORCE_COLOR` is in env, but honor 256', t => { + process.argv = ['--color=256']; + process.env.FORCE_COLOR = true; + const result = importFresh('.'); + t.truthy(result); + t.is(result.level, 2); +}); + +test('return true if `FORCE_COLOR` is in env, but honor 256', t => { + process.argv = ['--color=256']; + process.env.FORCE_COLOR = '1'; + const result = importFresh('.'); + t.truthy(result); + t.is(result.level, 2); +}); + +test('return false if `FORCE_COLOR` is in env and is 0', t => { + process.env.FORCE_COLOR = '0'; + const result = importFresh('.'); + t.false(result); +}); + +test('return false if not TTY', t => { process.stdout.isTTY = false; - assert.equal(requireUncached('./'), false); + const result = importFresh('.'); + t.false(result); }); -it('should return false if --no-color flag is used', function () { +test('return false if --no-color flag is used', t => { + process.env = {TERM: 'xterm-256color'}; process.argv = ['--no-color']; - assert.equal(requireUncached('./'), false); + const result = importFresh('.'); + t.false(result); }); -it('should return false if --no-colors flag is used', function () { +test('return false if --no-colors flag is used', t => { + process.env = {TERM: 'xterm-256color'}; process.argv = ['--no-colors']; - assert.equal(requireUncached('./'), false); + const result = importFresh('.'); + t.false(result); }); -it('should return true if --color flag is used', function () { +test('return true if --color flag is used', t => { process.argv = ['--color']; - assert.equal(requireUncached('./'), true); + const result = importFresh('.'); + t.truthy(result); }); -it('should return true if --colors flag is used', function () { +test('return true if --colors flag is used', t => { process.argv = ['--colors']; - assert.equal(requireUncached('./'), true); + const result = importFresh('.'); + t.truthy(result); }); -it('should return true if `COLORTERM` is in env', function () { +test('return true if `COLORTERM` is in env', t => { process.env.COLORTERM = true; - assert.equal(requireUncached('./'), true); + const result = importFresh('.'); + t.truthy(result); }); -it('should support `--color=true` flag', function () { +test('support `--color=true` flag', t => { process.argv = ['--color=true']; - assert.equal(requireUncached('./'), true); + const result = importFresh('.'); + t.truthy(result); }); -it('should support `--color=always` flag', function () { +test('support `--color=always` flag', t => { process.argv = ['--color=always']; - assert.equal(requireUncached('./'), true); + const result = importFresh('.'); + t.truthy(result); }); -it('should support `--color=false` flag', function () { +test('support `--color=false` flag', t => { + process.env = {TERM: 'xterm-256color'}; process.argv = ['--color=false']; - assert.equal(requireUncached('./'), false); + const result = importFresh('.'); + t.false(result); +}); + +test('support `--color=256` flag', t => { + process.argv = ['--color=256']; + const result = importFresh('.'); + t.truthy(result); +}); + +test('level should be 2 if `--color=256` flag is used', t => { + process.argv = ['--color=256']; + const result = importFresh('.'); + t.is(result.level, 2); + t.true(result.has256); +}); + +test('support `--color=16m` flag', t => { + process.argv = ['--color=16m']; + const result = importFresh('.'); + t.truthy(result); +}); + +test('support `--color=full` flag', t => { + process.argv = ['--color=full']; + const result = importFresh('.'); + t.truthy(result); +}); + +test('support `--color=truecolor` flag', t => { + process.argv = ['--color=truecolor']; + const result = importFresh('.'); + t.truthy(result); +}); + +test('level should be 3 if `--color=16m` flag is used', t => { + process.argv = ['--color=16m']; + const result = importFresh('.'); + t.is(result.level, 3); + t.true(result.has256); + t.true(result.has16m); +}); + +test('ignore post-terminator flags', t => { + process.argv = ['--color', '--', '--no-color']; + const result = importFresh('.'); + t.truthy(result); +}); + +test('allow tests of the properties on false', t => { + process.env = {TERM: 'xterm-256color'}; + process.argv = ['--no-color']; + const result = importFresh('.'); + t.is(result.hasBasic, undefined); + t.is(result.has256, undefined); + t.is(result.has16m, undefined); + t.false(result.level > 0); +}); + +test('return false if `CI` is in env', t => { + process.env.CI = 'AppVeyor'; + const result = importFresh('.'); + t.false(result); +}); + +test('return true if `TRAVIS` is in env', t => { + process.env = {CI: 'Travis', TRAVIS: '1'}; + const result = importFresh('.'); + t.truthy(result); +}); + +test('return true if `CIRCLECI` is in env', t => { + process.env = {CI: true, CIRCLECI: true}; + const result = importFresh('.'); + t.truthy(result); +}); + +test('return true if `APPVEYOR` is in env', t => { + process.env = {CI: true, APPVEYOR: true}; + const result = importFresh('.'); + t.truthy(result); +}); + +test('return true if `GITLAB_CI` is in env', t => { + process.env = {CI: true, GITLAB_CI: true}; + const result = importFresh('.'); + t.truthy(result); +}); + +test('return true if Codeship is in env', t => { + process.env = {CI: true, CI_NAME: 'codeship'}; + const result = importFresh('.'); + t.truthy(result); +}); + +test('return false if `TEAMCITY_VERSION` is in env and is < 9.1', t => { + process.env.TEAMCITY_VERSION = '9.0.5 (build 32523)'; + const result = importFresh('.'); + t.false(result); +}); + +test('return level 1 if `TEAMCITY_VERSION` is in env and is >= 9.1', t => { + process.env.TEAMCITY_VERSION = '9.1.0 (build 32523)'; + const result = importFresh('.'); + t.is(result.level, 1); +}); + +test('prefer level 2/xterm over COLORTERM', t => { + process.env = {COLORTERM: '1', TERM: 'xterm-256color'}; + const result = importFresh('.'); + t.is(result.level, 2); +}); + +test('support screen-256color', t => { + process.env = {TERM: 'screen-256color'}; + const result = importFresh('.'); + t.is(result.level, 2); +}); + +test('support putty-256color', t => { + process.env = {TERM: 'putty-256color'}; + const result = importFresh('.'); + t.is(result.level, 2); +}); + +test('level should be 3 when using iTerm 3.0', t => { + Object.defineProperty(process, 'platform', { + value: 'darwin' + }); + process.env = { + TERM_PROGRAM: 'iTerm.app', + TERM_PROGRAM_VERSION: '3.0.10' + }; + const result = importFresh('.'); + t.is(result.level, 3); +}); + +test('level should be 2 when using iTerm 2.9', t => { + Object.defineProperty(process, 'platform', { + value: 'darwin' + }); + process.env = { + TERM_PROGRAM: 'iTerm.app', + TERM_PROGRAM_VERSION: '2.9.3' + }; + const result = importFresh('.'); + t.is(result.level, 2); +}); + +test('return level 1 if on Windows earlier than 10 build 10586 and Node version is < 8.0.0', t => { + Object.defineProperty(process, 'platform', { + value: 'win32' + }); + Object.defineProperty(process.versions, 'node', { + value: '7.5.0' + }); + os.release = () => '10.0.10240'; + const result = importFresh('.'); + t.is(result.level, 1); +}); + +test('return level 1 if on Windows 10 build 10586 or later and Node version is < 8.0.0', t => { + Object.defineProperty(process, 'platform', { + value: 'win32' + }); + Object.defineProperty(process.versions, 'node', { + value: '7.5.0' + }); + os.release = () => '10.0.10586'; + const result = importFresh('.'); + t.is(result.level, 1); +}); + +test('return level 1 if on Windows earlier than 10 build 10586 and Node version is >= 8.0.0', t => { + Object.defineProperty(process, 'platform', { + value: 'win32' + }); + Object.defineProperty(process.versions, 'node', { + value: '8.0.0' + }); + os.release = () => '10.0.10240'; + const result = importFresh('.'); + t.is(result.level, 1); +}); + +test('return level 2 if on Windows 10 build 10586 or later and Node version is >= 8.0.0', t => { + Object.defineProperty(process, 'platform', { + value: 'win32' + }); + Object.defineProperty(process.versions, 'node', { + value: '8.0.0' + }); + os.release = () => '10.0.10586'; + const result = importFresh('.'); + t.is(result.level, 2); });