diff --git a/ansi-styles-2.1.0.tgz b/ansi-styles-2.1.0.tgz new file mode 100644 index 0000000..0d92089 Binary files /dev/null and b/ansi-styles-2.1.0.tgz differ diff --git a/nodejs-ansi-styles.spec b/nodejs-ansi-styles.spec new file mode 100644 index 0000000..be19482 --- /dev/null +++ b/nodejs-ansi-styles.spec @@ -0,0 +1,50 @@ +%{?nodejs_find_provides_and_requires} +%global enable_tests 1 +Name: nodejs-ansi-styles +Version: 2.1.0 +Release: 1 +Summary: ANSI escape codes for colorizing strings in the terminal +License: MIT +URL: https://github.com/sindresorhus/ansi-styles +Source0: http://registry.npmjs.org/ansi-styles/-/ansi-styles-%{version}.tgz +Source1: https://raw.githubusercontent.com/chalk/ansi-styles/v%{version}/test.js +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} noarch +BuildRequires: nodejs-packaging +%if 0%{?enable_tests} +BuildRequires: npm(mocha) npm(chalk) npm(require-uncached) +%endif +%description +%{summary}. + +%prep +%setup -q -n package +cp -p %{SOURCE1} . + +%build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/ansi-styles +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/ansi-styles +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +ln -s %{nodejs_sitelib}/chalk node_modules/chalk +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc readme.md +%license license +%{nodejs_sitelib}/ansi-styles + +%changelog +* Mon Aug 17 2020 Shaoqiang Kang - 2.1.0-1 +- Package init diff --git a/nodejs-ansi-styles.yaml b/nodejs-ansi-styles.yaml new file mode 100644 index 0000000..dc8e52f --- /dev/null +++ b/nodejs-ansi-styles.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: sindresorhus/ansi-styles +tag_prefix: "v" +seperator: "." diff --git a/test.js b/test.js new file mode 100644 index 0000000..5e17462 --- /dev/null +++ b/test.js @@ -0,0 +1,42 @@ +'use strict'; +var assert = require('assert'); +var ansi = require('./'); + +// generates the screenshot +Object.keys(ansi).forEach(function (el) { + var style = ansi[el].open; + + if (el === 'reset' || el === 'hidden') { + return; + } + + if (/^bg[^B]/.test(el)) { + style = ansi.black.open + style; + } + + process.stdout.write(style + el + ansi.reset.open + ansi.reset.close + ' '); +}); + +it('should return ANSI escape codes', function () { + assert.equal(ansi.green.open, '\u001b[32m'); + assert.equal(ansi.bgGreen.open, '\u001b[42m'); + assert.equal(ansi.green.close, '\u001b[39m'); + assert.equal(ansi.gray.open, ansi.grey.open); +}); + +it('should group related codes into categories', function () { + assert.equal(ansi.colors.magenta, ansi.magenta); + assert.equal(ansi.bgColors.bgYellow, ansi.bgYellow); + assert.equal(ansi.modifiers.bold, ansi.bold); +}); + +it('groups should not be enumerable', function () { + assert.equal(Object.keys(ansi).indexOf('modifiers'), -1); +}); + +it('should not pollute other objects', function () { + var obj1 = require('./'); + var obj2 = require('./'); + obj1.foo = true; + assert.notEqual(obj1.foo, obj2.foo); +});