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

Commit README.md file too #347

Closed
fabianmieller opened this issue Feb 19, 2019 · 11 comments
Closed

Commit README.md file too #347

fabianmieller opened this issue Feb 19, 2019 · 11 comments

Comments

@fabianmieller
Copy link

Hello,

I'm updating the version in the file README.md under "npm-scripts version" and I want to add this file to the same commit.

Are there solutions for that?

Thanks
Fabian

@itaisteinherz
Copy link
Collaborator

And more in general, it would be very helpful if np supported supplying a custom script to run when creating a new version commit.

@sindresorhus
Copy link
Owner

sindresorhus commented Feb 20, 2019

@itaisteinherz Agreed.

This depends on #279.

@itaisteinherz
Copy link
Collaborator

This depends on #279.

Why? It seems to me like this could be implemented even without having globally and locally configurable flags (e.g. using a default script that is run if configured, or an argument supplied directly to the CLI).

@itaisteinherz
Copy link
Collaborator

I just noticed this tip in the readme, which means that np already supports what I described above. However, when I tried using the version npm hook to add extra behavior when creating a new version, the new changes weren't committed with the version bump. This meant that I had to create another commit for the changes, which isn't the desired behavior here.

@sindresorhus We should probably add tips for using np with semantic release and standard version.

@sindresorhus
Copy link
Owner

We should probably add tips for using np with semantic release and standard version.

👍

@sindresorhus
Copy link
Owner

Why? It seems to me like this could be implemented even without having globally and locally configurable flags (e.g. using a default script that is run if configured, or an argument supplied directly to the CLI).

Sure, we could maybe add a CLI flag, but I don't want to end up with an endless amount of CLI flags. It's more readable and easier for users to add hooks as config. We'll probably need multiple hooks.

@simonhaenisch
Copy link

but I don't want to end up with an endless amount of CLI flags

Why not? ls has like 40 and I as a user don't have any issues with that 🤓 I just ignore all the ones I don't need...

It's more readable and easier for users to add hooks as config. We'll probably need multiple hooks.

Totally agree with this and I also think cosmiconfig would be a good choice for this because people have different preferences for how to write configs and that's ok. It's great if I don't have to write a super-long cli command with escaped quotes inside strings, and instead I can just put all the flags into a config file of my choice... however I might also only need one or two flags and a command in an npm script is better suited for me, so why not have both a flag and a config? Then it could also be possible to pass a flag to overwrite just one setting while still respecting the rest of my config.

@itaisteinherz
Copy link
Collaborator

itaisteinherz commented Feb 23, 2019

@simonhaenisch I'm pretty sure that what @sindresorhus meant is that we'll add support for configuration through config files using cosmiconfig, but will continue to support CLI arguments, just like AVA does.

@simonhaenisch
Copy link

This meant that I had to create another commit for the changes, which isn't the desired behavior here.

I think you could solve this by amending the version commit using the postversion hook, i. e.

{
  "scripts": {
    "version": "conventional-changelog", // or whatever updates the changelog
    "postversion": "git add CHANGELOG.md && git commit --amend --no-edit"
  }
}

Or you could try to add the modified file in the version hook (which is run before committing), i. e.

{
  "scripts": {
    "version": "conventional-changelog && git add CHANGELOG.md",
  }
}

(/cc @fabianmieller)

@itaisteinherz
Copy link
Collaborator

@simonhaenisch Thanks for the suggestions, but I already tried both and they didn't work. Sometimes the hooks never ran, and sometimes they ran after the version bump was committed. Sorry for the vague explanation, I'll try to look further into this in a few days.

@fabianmieller
Copy link
Author

@simonhaenisch works thanks!

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

4 participants