Cli: npm version not creating git commits when in sub-directory

Created on 8 Nov 2019  路  2Comments  路  Source: npm/cli

  Original bug ticket: [https://npm.community/t/9083](https://npm.community/t/9083)
  Originally filed: 2019-07-25T08:28:56.509Z
Bug Community

Most helpful comment

Workaround: create a postversion.sh file with following content and call it from npm script postversion:

git add package.json
git commit -m "chore: Bump version to $npm_package_version"
git tag -a $npm_config_tag_version_prefix$npm_package_version -m "$npm_package_version"
git push --follow-tags

npm sets up the environment variables npm_package_version and npm_config_tag_version_prefix automatically; which I can then use for commit message and tag name and annotation.

All 2 comments

I experience this problem as well.

Is there a workaround except manually doing the commit and setting the tag? Especially setting the tag is cumbersome as I need to extract the version from package.json and eventually take tag-version-prefix setting into account.

Some solution alternatives I could think of:

  1. Provide a command line option to override the git detection, e.g. --force-git or stg better
  2. Improve git detection, there is a apparently a PR for that: #221

Workaround: create a postversion.sh file with following content and call it from npm script postversion:

git add package.json
git commit -m "chore: Bump version to $npm_package_version"
git tag -a $npm_config_tag_version_prefix$npm_package_version -m "$npm_package_version"
git push --follow-tags

npm sets up the environment variables npm_package_version and npm_config_tag_version_prefix automatically; which I can then use for commit message and tag name and annotation.

Was this page helpful?
0 / 5 - 0 ratings