How does the npm version work?
I am a little confused about how it works . The documentation says: npm version
If you run the git repo, it will create the version and tag as well.
Does this mean I don't need to run git commit
or git tag
or is it just git tag -a <version>
? If I did something like this, would I create a double commit?
git add . -A
git commit -m "<commit message>"
git push origin master
npm version <patch|minor|major> -m "<version description>" ## instead of git tag -a <version> ##
git push --tags
source to share
Your understanding is mostly correct
When you execute the command npm version
, the following is executed:
- a convex version of the package, as
package.json
inpackage.json
- create a commit containing only the update for
package.json
with the message specified when callednpm version
. - create git tag
Then you can execute npm publish
to publish to the npm registry, and git will push your tag to the remote repository whenever you want.
Long answer
As for the exact commands that ours have executed since you've expressed interest in this through the comments:
adding files to the production:
git add /path/to/package.json
If the lock and shrinkwrap package files are also present, they are added as above as well!
creating a commit:
git commit -m {version message}
Regarding tag creation:
git tag {version no.} -am {version message}
or if signature is included:
git tag {version no.} -sm {version message}
For reference, version message
o version message
is required, if excluded from CLI input then it defaults to number version no.
,
source to share