Skip to content
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

Trimming the trailing newline (and more tips on migrating from execa/other packages) #36

Open
ziebam opened this issue Sep 8, 2024 · 4 comments

Comments

@ziebam
Copy link

ziebam commented Sep 8, 2024

When migrating execa to tinyexec in some projects, I've ran into a difference in the default behavior where execa would trim the trailing newline by default (https://github.com/sindresorhus/execa/blob/3fc804916d60b0b2e774a3642bd9815388caf7af/docs/lines.md?plain=1#L56-L63), whereas tinyexec wouldn't. I see two possible solutions for this issue:

  1. Trim by default in tinyexec. This could potentially introduce some unwanted complexity as disabling the behavior (stripFinalNewline option in execa) should also be supported then.
  2. Mention the difference in the documentation so that the consumers' can catch issues related to not stripping the trailing newline early and call .trim() on the returned output.
@43081j
Copy link
Collaborator

43081j commented Sep 8, 2024

I think we just need to document it, as it isn't the best thing to do by default (want to avoid implementing the same magic execa and others did, keeping things straight forward)

We probably just need a section explaining how to migrate

@ziebam ziebam changed the title Trimming the trailing newline Trimming the trailing newline (and more tips on migrating from execa/other packages) Sep 8, 2024
@ziebam
Copy link
Author

ziebam commented Sep 8, 2024

I'm happy to contribute to such a section once we settle on what structure it should follow!

@43081j
Copy link
Collaborator

43081j commented Sep 8, 2024

Sure, I think we should probably add a top level section for migration with a subsection for execa

Things in particular we should note:

  • newlines don't automatically get trimmed
  • errors are not thrown by default (but there's an option to make them be thrown)
  • many things child_process exposes should be accessed through the process getter (i.e we don't re-expose them all individually)

Let's try avoid listing every possible difference though and stick to the main few that might trip people up

@ghiscoding
Copy link

that'd be great, I maybe want to migrate from execa to tinyexec in Lerna-Lite (a lighter fork of Lerna used by Jest, Volar, ...) and I'm not sure where to start. Side note if any of you want to create a PR for that, I'd be super happy 😆

I recently migrated chalk to picolors (and quickly after to tinyrainbow because it has ESM exports) and also migrated to tinyglobby. On my possible list of TODOs, I have picomatch (though I'm waiting for an issue I've open to be resolved on their side) and tinyexec, it would be nice if I can do them all :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants