-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all
property to returned object
#5
Conversation
Ok, I should have been more clear in the original issue. It's not that simple. The user could already do this themselves. What I'm after is the combination of stdout and stderr as it's outputted, just like what you would see in your terminal. process.stdout.write('1');
process.stderr.write('2');
process.stdout.write('3'); Would result in Will probably have to spawn and gather it manually. |
I was wondering why you said you didn't have enough time to do this! I'll look into it. Thanks for clearing it up. |
All right, so I use However, if I do I am not sure if this is an error in my implementation, but let me know! |
Just create a |
All right, so this passes all the tests and seems to work, but (IMO) probably could be refactored/cleaned up.
A lot of stuff I did was new to me (I learned stuff at least!), so let me know what you think. |
You use e.g. |
var all = ''; | ||
|
||
spawned.stdout.on('data', function (data) { | ||
out += data.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using .toString()
is a common mistake in Node.js, but this will totally break on unicode where one character might be split between different data
chunks. Instead use .setEncoding()
upfront.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you supposed to use string-decoder for that? Or is that what setEncoding uses under the hood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamestalmage You could. I think it uses it under the hood, but .setEncoding()
is the correct way regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. I blame the Node.js docs. They could be a lot clearer. Especially since it's easy to do it wrong and would cause subtle bugs.
Hey Sindre, so my old |
Force push is fine, and often useful, on non-master branches. Your changes does not yet address all the previous inline feedback. |
Sure, was just explaining the force push! I'll get to work on the rest of the feedback. Thanks! |
All right, I took care of some of the smaller things. The Also, can you clarify on what I should do about this? |
Ha, I had forgotten about this PR. Yeah there's probably a better way to do this now. Might be worth to just close this one and I (or someone else?) can work with the new proposed solutions. |
This fixes #1 by returning an additional
all
property that is just thestderr
andstdout
together, updating the readme, and adding two tests that test this feature.