fuanan add package
This commit is contained in:
parent
e29566d18d
commit
4664d8deef
BIN
chalk-1.1.3.tgz
Normal file
BIN
chalk-1.1.3.tgz
Normal file
Binary file not shown.
25
chalk-fix-lack-of-dim.patch
Normal file
25
chalk-fix-lack-of-dim.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
diff --git a/index.js b/index.js
|
||||||
|
index 2d85a91..19b4b22 100644
|
||||||
|
--- a/index.js
|
||||||
|
+++ b/index.js
|
||||||
|
@@ -73,9 +73,9 @@ function applyStyle() {
|
||||||
|
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
|
||||||
|
// see https://github.com/chalk/chalk/issues/58
|
||||||
|
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
|
||||||
|
- var originalDim = ansiStyles.dim.open;
|
||||||
|
+ var originalDim = ansiStyles.gray.open;
|
||||||
|
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
|
||||||
|
- ansiStyles.dim.open = '';
|
||||||
|
+ ansiStyles.gray.open = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i--) {
|
||||||
|
@@ -88,7 +88,7 @@ function applyStyle() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
|
||||||
|
- ansiStyles.dim.open = originalDim;
|
||||||
|
+ ansiStyles.gray.open = originalDim;
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
32
chalk-fix-tests.patch
Normal file
32
chalk-fix-tests.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
diff --git a/test.js b/test.js
|
||||||
|
index a3aa8d6..8e3090a 100644
|
||||||
|
--- a/test.js
|
||||||
|
+++ b/test.js
|
||||||
|
@@ -46,9 +46,11 @@ describe('chalk', function () {
|
||||||
|
assert.notEqual(green('baz'), greenBold('baz'));
|
||||||
|
});
|
||||||
|
|
||||||
|
+/*
|
||||||
|
it('should alias gray to grey', function () {
|
||||||
|
assert.equal(chalk.grey('foo'), '\u001b[90mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
+*/
|
||||||
|
|
||||||
|
it('should support variable number of arguments', function () {
|
||||||
|
assert.equal(chalk.red('foo', 'bar'), '\u001b[31mfoo bar\u001b[39m');
|
||||||
|
@@ -102,6 +104,7 @@ describe('chalk on windows', function () {
|
||||||
|
assert.equal(chalkCtx.blue('foo'), '\u001b[34mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
+/*
|
||||||
|
it('should not apply dimmed styling on gray strings, see https://github.com/chalk/chalk/issues/58', function () {
|
||||||
|
process.env.TERM = 'dumb';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
@@ -119,6 +122,7 @@ describe('chalk on windows', function () {
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.blue.dim('foo'), '\u001b[94m\u001b[2mfoo\u001b[22m\u001b[39m');
|
||||||
|
});
|
||||||
|
+*/
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.enabled', function () {
|
||||||
21
license
Normal file
21
license
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@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.
|
||||||
62
nodejs-chalk.spec
Normal file
62
nodejs-chalk.spec
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
%{?nodejs_find_provides_and_requires}
|
||||||
|
%global enable_tests 0
|
||||||
|
Name: nodejs-chalk
|
||||||
|
Version: 1.1.3
|
||||||
|
Release: 1
|
||||||
|
Summary: Terminal string styling done right
|
||||||
|
License: MIT
|
||||||
|
URL: https://github.com/chalk/chalk
|
||||||
|
Source0: http://registry.npmjs.org/chalk/-/chalk-%{version}.tgz
|
||||||
|
Source1: https://raw.githubusercontent.com/chalk/chalk/v%{version}/test.js
|
||||||
|
Source2: https://raw.githubusercontent.com/chalk/chalk/v%{version}/license
|
||||||
|
Patch0: chalk-fix-lack-of-dim.patch
|
||||||
|
Patch1: chalk-fix-tests.patch
|
||||||
|
BuildArch: noarch
|
||||||
|
ExclusiveArch: %{nodejs_arches} noarch
|
||||||
|
ExclusiveArch: %{ix86} x86_64 %{arm} noarch
|
||||||
|
BuildRequires: nodejs-packaging npm(ansi-styles) npm(escape-string-regexp)
|
||||||
|
BuildRequires: npm(has-ansi) >= 2.0.0 npm(has-color) npm(strip-ansi) npm(supports-color)
|
||||||
|
%if 0%{?enable_tests}
|
||||||
|
BuildRequires: npm(mocha) npm(require-uncached) npm(semver)
|
||||||
|
%endif
|
||||||
|
%description
|
||||||
|
%{summary}.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -n package
|
||||||
|
cp -p %{SOURCE1} .
|
||||||
|
cp -p %{SOURCE2} .
|
||||||
|
%patch0 -p1
|
||||||
|
%patch1 -p1
|
||||||
|
%nodejs_fixdep has-color
|
||||||
|
%nodejs_fixdep ansi-styles '^2.0.0'
|
||||||
|
%nodejs_fixdep strip-ansi
|
||||||
|
%nodejs_fixdep supports-color
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}%{nodejs_sitelib}/chalk
|
||||||
|
cp -pr package.json index.js \
|
||||||
|
%{buildroot}%{nodejs_sitelib}/chalk
|
||||||
|
%nodejs_symlink_deps
|
||||||
|
|
||||||
|
%check
|
||||||
|
%nodejs_symlink_deps --check
|
||||||
|
%{__nodejs} -e 'require("./")'
|
||||||
|
%if 0%{?enable_tests}
|
||||||
|
ln -s %{nodejs_sitelib}/tape node_modules/tape
|
||||||
|
%{_bindir}/mocha -R spec
|
||||||
|
%else
|
||||||
|
%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m"
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%files
|
||||||
|
%{!?_licensedir:%global license %doc}
|
||||||
|
%doc *.md
|
||||||
|
%license license
|
||||||
|
%{nodejs_sitelib}/chalk
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Aug 17 2020 Anan Fu <fuanan3@huawei.com> - 1.1.3-1
|
||||||
|
- Package init
|
||||||
65
nodejs-chalk.spec.old
Normal file
65
nodejs-chalk.spec.old
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
%{?nodejs_find_provides_and_requires}
|
||||||
|
%global enable_tests 0
|
||||||
|
Name: nodejs-chalk
|
||||||
|
Version: 1.1.3
|
||||||
|
Release: 1
|
||||||
|
Summary: Terminal string styling done right
|
||||||
|
License: MIT
|
||||||
|
URL: https://github.com/sindresorhus/chalk
|
||||||
|
Source0: http://registry.npmjs.org/chalk/-/chalk-%{version}.tgz
|
||||||
|
Source1: https://raw.githubusercontent.com/chalk/chalk/v%{version}/test.js
|
||||||
|
Source2: https://raw.githubusercontent.com/chalk/chalk/v%{version}/license
|
||||||
|
Patch0: chalk-fix-lack-of-dim.patch
|
||||||
|
Patch1: chalk-fix-tests.patch
|
||||||
|
BuildArch: noarch
|
||||||
|
%if 0%{?fedora} >= 19
|
||||||
|
ExclusiveArch: %{nodejs_arches} noarch
|
||||||
|
%else
|
||||||
|
ExclusiveArch: %{ix86} x86_64 %{arm} noarch
|
||||||
|
%endif
|
||||||
|
BuildRequires: nodejs-packaging npm(ansi-styles) npm(escape-string-regexp)
|
||||||
|
BuildRequires: npm(has-ansi) >= 2.0.0 npm(has-color) npm(strip-ansi) npm(supports-color)
|
||||||
|
%if 0%{?enable_tests}
|
||||||
|
BuildRequires: npm(mocha) npm(require-uncached) npm(semver)
|
||||||
|
%endif
|
||||||
|
%description
|
||||||
|
%{summary}.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -n package
|
||||||
|
cp -p %{SOURCE1} .
|
||||||
|
cp -p %{SOURCE2} .
|
||||||
|
%patch0 -p1
|
||||||
|
%patch1 -p1
|
||||||
|
%nodejs_fixdep has-color
|
||||||
|
%nodejs_fixdep ansi-styles '^2.0.0'
|
||||||
|
%nodejs_fixdep strip-ansi
|
||||||
|
%nodejs_fixdep supports-color
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}%{nodejs_sitelib}/chalk
|
||||||
|
cp -pr package.json index.js \
|
||||||
|
%{buildroot}%{nodejs_sitelib}/chalk
|
||||||
|
%nodejs_symlink_deps
|
||||||
|
|
||||||
|
%check
|
||||||
|
%nodejs_symlink_deps --check
|
||||||
|
%{__nodejs} -e 'require("./")'
|
||||||
|
%if 0%{?enable_tests}
|
||||||
|
ln -s %{nodejs_sitelib}/tape node_modules/tape
|
||||||
|
%{_bindir}/mocha -R spec
|
||||||
|
%else
|
||||||
|
%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m"
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%files
|
||||||
|
%{!?_licensedir:%global license %doc}
|
||||||
|
%doc *.md
|
||||||
|
%license license
|
||||||
|
%{nodejs_sitelib}/chalk
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Aug 17 2020 Anan Fu <fuanan3@huawei.com> - 1.1.3-1
|
||||||
|
- Package init
|
||||||
4
nodejs-chalk.yaml
Normal file
4
nodejs-chalk.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
version_control: github
|
||||||
|
src_repo: chalk/chalk
|
||||||
|
tag_prefix: "^"
|
||||||
|
seperator: "."
|
||||||
157
test.js
Normal file
157
test.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
'use strict';
|
||||||
|
var assert = require('assert');
|
||||||
|
var requireUncached = require('require-uncached');
|
||||||
|
var resolveFrom = require('resolve-from');
|
||||||
|
var semver = require('semver');
|
||||||
|
var chalk = require('./');
|
||||||
|
|
||||||
|
describe('chalk', function () {
|
||||||
|
it('should style string', function () {
|
||||||
|
assert.equal(chalk.underline('foo'), '\u001b[4mfoo\u001b[24m');
|
||||||
|
assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m');
|
||||||
|
assert.equal(chalk.bgRed('foo'), '\u001b[41mfoo\u001b[49m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support applying multiple styles at once', function () {
|
||||||
|
assert.equal(chalk.red.bgGreen.underline('foo'), '\u001b[31m\u001b[42m\u001b[4mfoo\u001b[24m\u001b[49m\u001b[39m');
|
||||||
|
assert.equal(chalk.underline.red.bgGreen('foo'), '\u001b[4m\u001b[31m\u001b[42mfoo\u001b[49m\u001b[39m\u001b[24m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support nesting styles', function () {
|
||||||
|
assert.equal(
|
||||||
|
chalk.red('foo' + chalk.underline.bgBlue('bar') + '!'),
|
||||||
|
'\u001b[31mfoo\u001b[4m\u001b[44mbar\u001b[49m\u001b[24m!\u001b[39m'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support nesting styles of the same type (color, underline, bg)', function () {
|
||||||
|
assert.equal(
|
||||||
|
chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
|
||||||
|
'\u001b[31ma\u001b[33mb\u001b[32mc\u001b[33mb\u001b[31mc\u001b[39m'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reset all styles with `.reset()`', function () {
|
||||||
|
assert.equal(chalk.reset(chalk.red.bgGreen.underline('foo') + 'foo'), '\u001b[0m\u001b[31m\u001b[42m\u001b[4mfoo\u001b[24m\u001b[49m\u001b[39mfoo\u001b[0m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to cache multiple styles', function () {
|
||||||
|
var red = chalk.red;
|
||||||
|
var green = chalk.green;
|
||||||
|
var redBold = red.bold;
|
||||||
|
var greenBold = green.bold;
|
||||||
|
|
||||||
|
assert.notEqual(red('foo'), green('foo'));
|
||||||
|
assert.notEqual(redBold('bar'), greenBold('bar'));
|
||||||
|
assert.notEqual(green('baz'), greenBold('baz'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should alias gray to grey', function () {
|
||||||
|
assert.equal(chalk.grey('foo'), '\u001b[90mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support variable number of arguments', function () {
|
||||||
|
assert.equal(chalk.red('foo', 'bar'), '\u001b[31mfoo bar\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should support falsy values', function () {
|
||||||
|
assert.equal(chalk.red(0), '\u001b[31m0\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('don\'t output escape codes if the input is empty', function () {
|
||||||
|
assert.equal(chalk.red(), '');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk on windows', function () {
|
||||||
|
var originalEnv;
|
||||||
|
var originalPlatform;
|
||||||
|
|
||||||
|
// in node versions older than 0.12.x process.platform cannot be overridden
|
||||||
|
if (semver.lt(process.version, '0.12.0')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
originalEnv = process.env;
|
||||||
|
originalPlatform = process.platform;
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
process.env = originalEnv;
|
||||||
|
Object.defineProperty(process, 'platform', {value: originalPlatform});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
process.env = {};
|
||||||
|
Object.defineProperty(process, 'platform', {value: 'win32'});
|
||||||
|
// since chalk internally modifies ansiStyles.blue.open, ansi-styles needs
|
||||||
|
// to be removed from the require cache for require-uncached to work
|
||||||
|
delete require.cache[resolveFrom(__dirname, 'ansi-styles')];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should replace blue foreground color in cmd.exe', function () {
|
||||||
|
process.env.TERM = 'dumb';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.blue('foo'), '\u001b[94mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shouldn\'t replace blue foreground color in xterm based terminals', function () {
|
||||||
|
process.env.TERM = 'xterm-256color';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.blue('foo'), '\u001b[34mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not apply dimmed styling on gray strings, see https://github.com/chalk/chalk/issues/58', function () {
|
||||||
|
process.env.TERM = 'dumb';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.gray.dim('foo'), '\u001b[90mfoo\u001b[22m\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should apply dimmed styling on xterm compatible terminals', function () {
|
||||||
|
process.env.TERM = 'xterm';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.gray.dim('foo'), '\u001b[90m\u001b[2mfoo\u001b[22m\u001b[39m');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should apply dimmed styling on strings of other colors', function () {
|
||||||
|
process.env.TERM = 'dumb';
|
||||||
|
var chalkCtx = requireUncached('./');
|
||||||
|
assert.equal(chalkCtx.blue.dim('foo'), '\u001b[94m\u001b[2mfoo\u001b[22m\u001b[39m');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.enabled', function () {
|
||||||
|
it('should not output colors when manually disabled', function () {
|
||||||
|
chalk.enabled = false;
|
||||||
|
assert.equal(chalk.red('foo'), 'foo');
|
||||||
|
chalk.enabled = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.constructor', function () {
|
||||||
|
it('should create a isolated context where colors can be disabled', function () {
|
||||||
|
var ctx = new chalk.constructor({enabled: false});
|
||||||
|
assert.equal(ctx.red('foo'), 'foo');
|
||||||
|
assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.styles', function () {
|
||||||
|
it('should expose the styles as ANSI escape codes', function () {
|
||||||
|
assert.equal(chalk.styles.red.open, '\u001b[31m');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.hasColor()', function () {
|
||||||
|
it('should detect whether a string has color', function () {
|
||||||
|
assert(chalk.hasColor(chalk.green('foo')));
|
||||||
|
assert(!chalk.hasColor(chalk.stripColor(chalk.green('foo'))));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('chalk.stripColor()', function () {
|
||||||
|
it('should strip color from string', function () {
|
||||||
|
assert.equal(chalk.stripColor(chalk.underline.red.bgGreen('foo')), 'foo');
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user