zoukankan      html  css  js  c++  java
  • husky+commitlint配置步骤

    husky v7+ 及 commitlint v13+ 配置方法都有很大改变,  原有的配置方法已经不再使用

    安装git-hook工具

    yarn add  husky -D

    在当前目录下生成.husky文件夹,并删除里面的.gitignore忽略文件,否则无法将.husky下面的文件提交到git仓库

    yarn husky install

    在.husky文件夹下创建commit-msg文件,注意不要修改commit-msg这个文件的名称,否则husky功能会失效

    npx husky add .husky/commit-msg

    在.husky/commit-msg文件中写入

    #!/bin/sh
    . "$(dirname "$0")/_/husky.sh"
    # 提交记录检查
    yarn commitlint --edit $1
    # 格式化检查
    yarn format:check
    # eslint检查
    yarn lint:check

    将.husky/commit-msg添加到代码仓库

    git add .husky/commit-msg

    安装git 提交信息规范配置文件

    yarn  add -D @commitlint/{cli,config-conventional} 

    安装changelog自动化生成工具

    yarn add -D conventional-changelog-cli

    package.json的script中添加

    {
        "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
        "changelog:init": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
        "changelog:help": "conventional-changelog --help",
    },
    • 参数-p指定提交信息的规范,有以下选择:angular, atom, codemirror, ember, eslint, express, jquery, jscs or jshint
    • 参数-s 表示将新生成的CHANGELOG输出到-i指定的文件中
    • 参数-i 指定输出CHANGELOG内容的文件
    • 参数-r默认为1,设为0将重新生成所有版本的变更信息
  • 相关阅读:
    【SQL】行转列
    【SQL】高级函数汇总
    VisualStudio优秀扩展插件推荐
    【SQL】多行转一列 FOR XML PATH
    【SQL】判断一个字符串是否在另外一个字符串中
    【NodeJS】Windows环境初始化
    【WPF】实现加载中动画效果
    C# ffmpeg简单帮助类
    ZSH出现问题
    Manjaro 安装后的配置
  • 原文地址:https://www.cnblogs.com/wangpenghui522/p/15518836.html
Copyright © 2011-2022 走看看