gpt4 book ai didi

javascript - 如何在 npm 版本期间运行脚本

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:15:55 25 4
gpt4 key购买 nike

有没有办法在 npm version 期间运行脚本,该脚本在版本号增加之后但在创建和推送 git 标签之前运行?

最佳答案

您可以创建一个 version 脚本,一旦包版本增加但在提交和标记之前将被调用。

"scripts": {
"version": "./your_script"
}

根据npm version查看执行顺序文档。您可以在下面看到有趣的摘录,特别是第 4 点:

  1. Check to make sure the git working directory is clean before we get started. Your scripts may add files to the commit in future steps. This step is skipped if the --force flag is set.
  2. Run the preversion script. These scripts have access to the old version in package.json. A typical use would be running your full test suite before deploying. Any files you want added to the commit should be explicitly added using git add.
  3. Bump version in package.json as requested (patch, minor, major, etc).
  4. Run the version script. These scripts have access to the new version in package.json (so they can incorporate it into file headers in generated files for example). Again, scripts should explicitly add generated files to the commit using git add.
  5. Commit and tag.
  6. Run the postversion script. Use it to clean up the file system or automatically push the commit and/or tag.

此功能是在 npm v2.13.0 中引入的.参见 version: allow scripts to add files to the commit了解更多信息。

关于javascript - 如何在 npm 版本期间运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com