feat!: refactor to use execa & add git check working tree #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a hot take. Multiple things are going on.
Breaking:
context.pinion.exec
runs https://github.com/sindresorhus/execa instead ofchild_process
. I know it's another dependency, but it's sooo much nicer to use (Promises)!The breaking change is:
context.pinion.exec
does not returnPromise<number>
anymore butPromise<ExecaChildProcess>
. That we can accessstdout
easily, which is needed for a lot of operations (e.g.npm
,git
,yarn
,npx npm-check-updates
, you name it). Having that at your fingertips withcontext.pinion.exec
is really nice! I think it's worth the breaking change.Feat:
I consider this to be a core functionality. It checks if
cwd
is a git repository and if the working tree is clean. It shows a prompt to confirm, if the working tree is not clean.Discussion:
I've added public utilities:
utilExec
,utilGitHasProjectGit
. Imo they should be publicly available so developers can use them to get thing started easily. There are several problems with these utils, that are meant to be used in generators, but aren't generators:@feathershq/pinion
gets polluted very fast with every new util.utilExec
andutilGitHasProjectGit
help with 1. but not really with 2.. I think the best approach is to publish them under a separate folder or even package. Maybe this:I think having a good set of common utils is a key factor to a fast adoption.
What do you think @daffl? Is
@feathershq/pinion-utils
the way to go?@pinion/utils
would be nicer though.