commit
a7d8a81e51
BIN
gzip-size-3.0.0.tgz
Normal file
BIN
gzip-size-3.0.0.tgz
Normal file
Binary file not shown.
50
nodejs-gzip-size.spec
Normal file
50
nodejs-gzip-size.spec
Normal file
@ -0,0 +1,50 @@
|
||||
%{?nodejs_find_provides_and_requires}
|
||||
%global enable_tests 0
|
||||
Name: nodejs-gzip-size
|
||||
Version: 3.0.0
|
||||
Release: 1
|
||||
Summary: Get the gzipped size of a string or buffer
|
||||
License: MIT
|
||||
URL: https://github.com/sindresorhus/gzip-size
|
||||
Source0: http://registry.npmjs.org/gzip-size/-/gzip-size-%{version}.tgz
|
||||
Source1: https://raw.githubusercontent.com/sindresorhus/gzip-size/v%{version}/test.js
|
||||
BuildArch: noarch
|
||||
ExclusiveArch: %{nodejs_arches} noarch
|
||||
BuildRequires: nodejs-packaging
|
||||
%if 0%{?enable_tests}
|
||||
BuildRequires: npm(ava) npm(concat-stream) npm(zlib-browserify)
|
||||
%endif
|
||||
%description
|
||||
%{summary}.
|
||||
|
||||
%prep
|
||||
%setup -q -n package
|
||||
cp -p %{SOURCE1} .
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{nodejs_sitelib}/gzip-size
|
||||
cp -pr package.json index.js \
|
||||
%{buildroot}%{nodejs_sitelib}/gzip-size
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
ln -sf %{nodejs_sitelib}/gzip-size/index.js \
|
||||
%{buildroot}%{_bindir}/gzip-size
|
||||
%nodejs_symlink_deps
|
||||
%if 0%{?enable_tests}
|
||||
|
||||
%check
|
||||
%nodejs_symlink_deps --check
|
||||
%__nodejs tap.js
|
||||
%endif
|
||||
|
||||
%files
|
||||
%{!?_licensedir:%global license %doc}
|
||||
%doc *.md
|
||||
%license license
|
||||
%{nodejs_sitelib}/gzip-size
|
||||
%{_bindir}/gzip-size
|
||||
|
||||
%changelog
|
||||
* Thu Aug 20 2020 yaokai <yaokai13@huawei.com> - 3.0.0-1
|
||||
- Package init
|
||||
4
nodejs-gzip-size.yaml
Normal file
4
nodejs-gzip-size.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
version_control: github
|
||||
src_repo: sindresorhus/gzip-size
|
||||
tag_pattern: "^v"
|
||||
seperator: "."
|
||||
63
test.js
Normal file
63
test.js
Normal file
@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
var fs = require('fs');
|
||||
var tap = require('tap');
|
||||
var gzipSize = require('./');
|
||||
var a = fs.readFileSync('test.js', 'utf8');
|
||||
|
||||
tap.test('get the gzipped size', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
gzipSize(a, function (err, size) {
|
||||
t.assert(!err);
|
||||
t.assert(size < a.length);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('sync - get the gzipped size', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
t.assert(gzipSize.sync(a) < a.length);
|
||||
});
|
||||
|
||||
tap.test('sync - match async version', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
gzipSize(a, function (err, size) {
|
||||
t.assert(!err);
|
||||
t.assert(gzipSize.sync(a) === size);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('stream', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
fs.createReadStream('test.js')
|
||||
.pipe(gzipSize.stream())
|
||||
.on('end', function () {
|
||||
t.equal(this.gzipSize, gzipSize.sync(a));
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('gzip-size event', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
fs.createReadStream('test.js')
|
||||
.pipe(gzipSize.stream())
|
||||
.on('gzip-size', function (size) {
|
||||
t.equal(size, gzipSize.sync(a));
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('passthrough', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var out = '';
|
||||
fs.createReadStream('test.js')
|
||||
.pipe(gzipSize.stream())
|
||||
.on('data', function (buf) {
|
||||
out += buf;
|
||||
})
|
||||
.on('end', function () {
|
||||
t.equal(out, a);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user