Skip to content

Commit

Permalink
fix(pipe) empty stream | write file error: rm pipeline (nodejs/node/i…
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Nov 21, 2018
1 parent a396baf commit 83a3c7d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 39 deletions.
1 change: 0 additions & 1 deletion README.md
@@ -1,7 +1,6 @@
Pipe-io [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
=========
Pipe [streams](https://github.com/substack/stream-handbook) and handle events.
Uses [stream.pipeline](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_stream_pipeline_streams_callback) where can.

## Install

Expand Down
4 changes: 0 additions & 4 deletions lib/pipe.js
Expand Up @@ -3,7 +3,6 @@
const fs = require('fs');
const zlib = require('zlib');
const assert = require('assert');
const pipeline = require('stream').pipeline;

module.exports = (streams, options, callback) => {
if (!callback) {
Expand All @@ -19,9 +18,6 @@ module.exports = (streams, options, callback) => {
assert(streams, 'streams could not be empty!');
assert(callback, 'callback could not be empty!');

if (options.end && pipeline)
return pipeline(streams, callback);

pipe(streams, options, callback);
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -33,7 +33,6 @@
"eslint": "^5.3.0",
"eslint-plugin-node": "^8.0.0",
"gunzip-maybe": "^1.4.1",
"mock-require": "^3.0.2",
"nodemon": "^1.11.0",
"nyc": "^13.0.1",
"pullout": "^3.0.0",
Expand Down
33 changes: 0 additions & 33 deletions test/pipe.js
Expand Up @@ -8,18 +8,13 @@ const zlib = require('zlib');
const {Readable} = require('stream');

const through2 = require('through2');
const pump = require('pump');
const {promisify} = require('util');
const stream = require('stream');
const {pipeline} = stream;
stream.pipeline = null;

const tryToTape = require('try-to-tape');
const tar = require('tar-fs');
const gunzip = require('gunzip-maybe');
const pullout = require('pullout');
const tryToCatch = require('try-to-catch');
const {reRequire} = require('mock-require');

const pipe = require('..');
const _pipe = promisify(pipe);
Expand Down Expand Up @@ -64,34 +59,6 @@ test('file1 | gunzip maybe: error', async (t) => {
t.end();
});

test('file1 | file2: pipeline', async (t) => {
stream.pipeline = pipeline;

const pipe = promisify(reRequire('..'));
const file = fs.createReadStream('/hello');

const [e] = await tryToCatch(pipe, [file, gunzip()])

stream.pipeline = null;

t.equal(e.code, 'ENOENT', 'should return error');
t.end();
});

test('file1 | file2: pipeline for node < 10', async (t) => {
stream.pipeline = pump;

const pipe = promisify(reRequire('..'));
const file = fs.createReadStream('/hello');

const [e] = await tryToCatch(pipe, [file, gunzip()])

stream.pipeline = null;

t.equal(e.code, 'ENOENT', 'should return error');
t.end();
});

test('file1 | file2: no error', async (t) => {
const tmp = os.tmpdir();
const name = path.basename(__filename);
Expand Down

0 comments on commit 83a3c7d

Please sign in to comment.