sindresorhus / get-stdin

Get stdin as a string or buffer
MIT License
337 stars 28 forks source link

Break line present at the end #22

Closed Kikobeats closed 7 years ago

Kikobeats commented 7 years ago

I'm using get-sdtdin at regexgen-cli and I noticed that an \n is always present at the final of the input:

getStdin().then(stdin => {
  console.log(stdin)
  console.log([].concat(stdin))
})
❯ echo hola | regexgen
hola

[ 'hola\n' ]
sindresorhus commented 7 years ago

And what is the problem exactly? This module just consumes the whole stdin, the last \n produced by echo included.

Kikobeats commented 7 years ago

If this behavior is the expected then is ok and is my reponsability clean or not the break line 😄

sindresorhus commented 7 years ago

Yes, it's expected. In execa, I use strip-eof to remove it. Might be helpful for you too.

Kikobeats commented 7 years ago

Thanks!