@142vip/commit-linter
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.2 • Public • Published

@142vip/commit-linter

NPM version

Git Commit信息校验工具,统一团队提交规范

安装

# 安装
pnpm i @142vip/commit-linter -D

使用

const { type, scope, subject, commit } = commitLiner({
  // scopes 为可选参数
  scopes: ['release'],
})

// 配置
/**
 * Git Commit信息校验参数
 */
export interface GitCommitLinterOptions {
  /**
   * Git Commit支持的Type列表,默认支持:
   */
  types?: string[]
  /**
   * Git Commit支持的Scope列表
   */
  scopes?: string[]
}

最佳实践

创建verify-commit.ts文件,添加如下代码:

import { commitLiner } from '@142vip/commit-linter'
import { VipColor, VipConsole, vipLogger } from '@142vip/utils'

/**
 * 验证Git Commit信息
 */
async function verifyCommitMain(): Promise<void> {
  const { type, scope, subject, commit } = commitLiner()

  // 提交符合规范,打印相关信息
  VipConsole.log(`type: ${type}, scope: ${scope}, subject: ${subject}`)
  vipLogger.logByBlank(`${VipColor.greenBright('Git Commit: ')} ${VipColor.green(commit)}`)
}

void verifyCommitMain()

修改package.json文件,配置check:commit命令,添加如下代码:

{
  "scripts": {
    "check:commit": "npx node --loader ts-node/esm --no-warnings scripts/core/verify-commit.ts"
  }
}

证书

MIT

Copyright (c) 2019-present, 142vip 储凡

Package Sidebar

Install

npm i @142vip/commit-linter

Weekly Downloads

48

Version

0.0.1-alpha.2

License

MIT

Unpacked Size

22.2 kB

Total Files

8

Last publish

Collaborators

  • mmdapl