Skip to content
Myr

add max-buffer support (#37)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* add max-buffer support * incorporate PR feedback

authored by James Talmage · committed by James Talmage · parent 1d8f3a4 · Browse files · 4 files+33 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+33 added−7 removed

  • other:+33 added−7 removed

4 files+33 added−7 removed

added:fixtures/max-buffer+6 added
1#!/usr/bin/env node2'use strict';3var output = process.argv[2];4var amount = Number(process.argv[3]);56process[output].write(new Array(amount).join('.') + '\n');
modified:index.js+16 added-6 removed
91 unmodified lines
9293 return fn(file, args, opts);94}9596function getStream(stream, encoding) {97 if (!stream) {96function getStream(process, stream, encoding, maxBuffer) {97 if (!process[stream]) {98 return null;99 }100101 var ret;102103 if (encoding) {102 return _getStream(stream, {encoding: encoding});104 ret = _getStream(process[stream], {encoding: encoding, maxBuffer: maxBuffer});105 } else {106 ret = _getStream.buffer(process[stream], {maxBuffer: maxBuffer});107 }104 return _getStream.buffer(stream);108109 return ret.catch(function (err) {110 err.stream = stream;111 err.message = stream + ' ' + err.message;112 throw err;113 });114}115116function processDone(spawned) {117 return new Promise(function (resolve) {
9 unmodified lines
127128module.exports = function (cmd, args, opts) {129 var parsed = handleArgs(cmd, args, opts);130 var encoding = parsed.opts.encoding;131 var maxBuffer = parsed.opts.maxBuffer;132 var spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);133134 var promise = Promise.all([135 processDone(spawned),126 getStream(spawned.stdout, encoding),127 getStream(spawned.stderr, encoding)136 getStream(spawned, 'stdout', encoding, maxBuffer),137 getStream(spawned, 'stderr', encoding, maxBuffer)138 ]).then(function (arr) {139 var result = arr[0];140 var stdout = arr[1];141 var stderr = arr[2];
85 unmodified lines
modified:package.json+1 added-1 removed
modified:test.js+10 added