rsyncwrapper
rsyncwrapper copied to clipboard
Pipe all stdio in Windows. Fixes #50.
I know it's been a while, but I finally got around to looking into why my terminal colors keep getting messed up. If I use pipe for all three channels (the default setting for child_process.spawn) the problem goes away.
I'm not sure why it was setup this way in the first place, so let me know if you see any issues with this change. I did a little light testing on Node 10 and 12 and everything worked great.
Fixes #50
Cheers! I tracked down the change to that line and looks like it was introduced in this PR:
https://github.com/jedrichards/rsyncwrapper/pull/25
To be honest, not sure which IO setup is more useful/idiomatic. My instinct is that maybe your version is best, using the defaults.
Good catch. I don't use the interactive password prompt, so I missed the fact that my original solution did break it.
I spent the better part of the day trying to understand why. I think it has to do with the fact that the stdout and stderr pipes are not TTYs and so the colors aren't interpreted correctly. The updated version that I just pushed is kind of hideous, but it does preserve colors and allow for interactive password input in my testing.
I'm less sure about this approach though. As I see it, the real crux of the problem is that when we use stdio: 'pipe' (which is the default) ssh/rsync will present the password prompt, but immediately give 3 permission denied errors as if an incorrect password was entered and then exit. I can't understand why the process doesn't wait for user input when the password prompt is presented. Of course, the process does wait correctly if we allow it to inherit the parent's stdin, but then the colors get messed up.
I also don't have a *nix machine handy to test this on, but it should be fine.
One last comment of interest. Another rsync wrapper does use stdio: 'pipe' (see code here), so it must be possible, but I couldn't figure out what they did differently to make it work with the password prompt.
Another rsync wrapper
What the heck? All this time and I thought rsyncwrapper was the only Node rsync game in town! Plucky devil to go ahead and call the package rsync straight up 😄
but I couldn't figure out what they did differently to make it work with the password prompt
Seems like the only main difference in the relevant bit of code on rsync is passing in the cwd and env options ... does that make any difference?
The updated version that I just pushed is kind of hideous
It's not too bad at all, pretty readable, I'll test it here tomorrow (I'm on a *nix machine)
Plucky devil to go ahead and call the package rsync straight up
Haha, I know, the nerve. :)
I did try passing in process.cwd() and process.env to the child process, but it has no discernible effect.
Maybe we should also ping @bitzl since he wrote the original pull request and might have insights on this?