npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

happy-git-commit-message-checker

v1.0.5

Published

>自动检测git commit message是否符合语法

Downloads

39

Readme

git commit message 语法检测

自动检测git commit message是否符合语法

安装

npm install happy-git-commit-message-checker --save-dev

语法规则

message -> desc | kws

desc -> line + EOL + line...

line -> 【 + tag + 】 + txt

tag -> txt + postfix

postfix -> {'页'|'模块'...}

kws -> {'build'|'release','merge'...}

txt -> {^【,^】}

备注

  • txt是由非【、】字符组成的字符串,其中首字符不能是空白字符,如果txt中需要出现【或】,需要转义

  • 【、】转义规则:两侧用引号包裹,如“【”或‘【’或'【'或"【"

  • postfixkws是可以拓展的,系统支持传入自定义数值。

用法示例

  • 【测试页】这里需要有一段描述
  • 【测试模块】这里需要有一段描述
  • build
  • merge
  • release

测试用例

测试用例

API

runner(message, [customKeywords], [custormPostfixes])

自动检测,会自动设置好exitCode,如果message不符合要求,会自动在程序执行完后终止commit,底层封装了checker

  • customKeywords[array]:自定义关键词,系统自带的有build、Build、release、Release、merge、Merge,其中对乌龟Git自动merge生成的message做了兼容处理。用户可以自己传入关键词,进行拓展。

  • custormPostfixes[array]:自定义后缀,系统自带的后缀有“页”和“模块”,也就是【xx页|模块】,如果想要拓展,可以自己传参,例如支持【xx组件】,只需将custormPostfixes设为['组件']即可。

返回值:undefined

checker(message, [customKeywords], [custormPostfixes])

只进行检测,返回状态码,不设置exitCode**(exitCode非0都会导致commit终止)**

返回值:{status:string:}

getStatus()

返回值:{status:number:desc:string}

附录

如何获取commit message?

需要调用者自己读取/.git/COMMIT_EDITMSG文件内容,在commit-msg钩子触发时,Git会自动将message写入COMMIT_EDITMSG文件,读取即可