package init

This commit is contained in:
wang_yue111 2020-09-01 17:12:34 +08:00
parent 0d57a1eba8
commit 3127dc2515
5 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,45 @@
commit 4145b1c18762a46af04be129aec48eed30754956
Author: Tom Hughes <tom@compton.nu>
Date: Thu Dec 31 12:18:02 2015 +0000
Wait until the next tick to pause the stream
Registering handlers on a stream with `on` causes resume to be
called, but only on the next tick.
This leads to a race condition where the pause can happen before
that delayed resume, which then resumes the stream earlier than we
were expecting.
diff --git a/test/readdirp-stream.js b/test/readdirp-stream.js
index c43d132..e45bab5 100644
--- a/test/readdirp-stream.js
+++ b/test/readdirp-stream.js
@@ -252,16 +252,19 @@ test('\napi separately', function (t) {
t.equals(data, processedData, 'emits the buffered data');
t.ok(resumed, 'emits data only after it was resumed');
})
- .pause()
- api.processEntry(processedData);
- api.handleError(nonfatalError);
- api.handleFatalError(fatalError);
+ process.nextTick(function() {
+ api.stream.pause();
+
+ api.processEntry(processedData);
+ api.handleError(nonfatalError);
+ api.handleFatalError(fatalError);
- setTimeout(function () {
- resumed = true;
- api.stream.resume();
- }, 1)
+ setTimeout(function () {
+ resumed = true;
+ api.stream.resume();
+ }, 1)
+ })
})
t.test('\n# when a stream is paused it stops walking the fs', function (t) {

54
nodejs-readdirp.spec Normal file
View File

@ -0,0 +1,54 @@
%{?nodejs_find_provides_and_requires}
%global enable_tests 1
Name: nodejs-readdirp
Version: 2.1.0
Release: 1
Summary: Recursive version of Node's fs.readdir with a streaming API
License: MIT
URL: https://github.com/thlorenz/readdirp
Source0: https://registry.npmjs.org/readdirp/-/readdirp-%{version}.tgz
#git clone git://github.com/thlorenz/readdirp.git
#cd readdirp
#git archive --prefix="test/" --format=tar tags/v%{version}:test/ | bzip2 > tests-%{version}.tar.bz2
Source1: tests-v%{version}.tar.bz2
Patch0: nodejs-readdirp-pause.patch
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
BuildRequires: nodejs-packaging
%if 0%{?enable_tests}
BuildRequires: npm(graceful-fs) npm(minimatch) npm(proxyquire) npm(readable-stream)
BuildRequires: npm(set-immediate-shim) npm(tap) npm(through2)
%endif
%description
%{summary}.
%prep
%setup -q -n package
rm -rf test/
%setup -q -T -D -a 1 -n package
%patch0 -p1
find . -type f -exec chmod -x '{}' \;
%nodejs_fixdep minimatch "^3.0.0"
%build
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/readdirp
cp -pr package.json readdirp.js stream-api.js \
%{buildroot}%{nodejs_sitelib}/readdirp
%nodejs_symlink_deps
%if 0%{?enable_tests}
%check
%nodejs_symlink_deps --check
%__tap test/*.js
%endif
%files
%doc README.md examples/
%license LICENSE
%{nodejs_sitelib}/readdirp
%changelog
* Sat Aug 22 2020 wangyue <wangyue92@huawei.com> - 2.1.0-1
- package init

5
nodejs-readdirp.yaml Normal file
View File

@ -0,0 +1,5 @@
git_url: https://github.com/thlorenz/readdirp
version_control: github
src_repo: thlorenz/readdirp
tag_prefix: "^"
seperator: "."

BIN
readdirp-2.1.0.tgz Normal file

Binary file not shown.

BIN
tests-v2.1.0.tar.bz2 Normal file

Binary file not shown.