在“npm version”命令中跳过预提交挂钩

问题描述 投票:7回答:3

npm version将更改提交到package.json并创建一个标记。有没有办法防止在使用此命令时执行挂钩?

javascript git npm pre-commit-hook
3个回答
6
投票

不知道为什么之前这个功能在npm中不存在,但是我在不久前做出了贡献,因为我自己需要它。它与[email protected]一起发货。要使用它,请在commit-hooks = false中设置配置选项.npmrc,并且在创建版本提交时,底层git调用将不会运行提交挂钩。如果您只想在单个版本控制上禁用提交挂钩,则可以运行类似于:

npm version --no-commit-hooks minor

或者:

npm version --commit-hooks false minor

2
投票

根据npm cli docs,您可以通过使用跳过git标记的生成

npm --no-git-tag-version version

1
投票

来自docs

提交钩

  • 默认值:true
  • 类型:布尔值

使用npm version命令时运行git commit hooks。

如果你只是想让这一次运行,请关注

npm version --no-commit-hooks patch|minor|major

要永久控制它,请运行以下命令

npm config set commit-hooks false

或者将此行添加到.npmrc文件中

commit-hooks=false

© www.soinside.com 2019 - 2024. All rights reserved.