@4th-motion/git-hooks 中文文档教程

发布于 4年前 浏览 70 项目主页 更新于 3年前

@4th-motion/git-hooks

易于设置可以在项目之间共享的 git 挂钩。

版本 License

在一个地方处理所有 git hooks 并在项目之间共享它们。 可以随时进行更改 - 旧配置会自动覆盖,因为只有一个真实来源。


Terminal


Installation

将此包作为 devDependency 添加到您的项目中:

yarn add --dev @4th-motion/git-hooks


Usage

安装包后,您可以通过以下方式启动它:

yarn 4th-git-hooks

现在您可以指定要在特定挂钩上执行的任务。 任务必须出现在 package.jsonscript 字段中。

{
  "git": {
    "pre-commit": ["lint", "test"]
  }
}

请注意,commit-msg 挂钩始终会执行。 这确保只能使用特定关键字(例如 featfix ……)推送提交,而永远不会推送到 master 分支。 如果您不想激活此挂钩,只需将其从 hooks/ 文件夹中删除。


Behind the scenes

初始化过程将 package.json 文件扩展为如下:

{
  "scripts": {
    "postinstall": "4th-git-hooks"
  }
}

这将在每次安装期间从 hooks/ 目录复制所有 git-hooks。 您始终可以编辑现有的挂钩或添加新的挂钩。 可以在此处 找到所有 git 钩子的列表。


Further documents


Related projects

@4th-motion/eslint-config@4th-motion/stylelint-config
@4th-motion/eslint-config@4th-motion/stylelint-config


License

版权所有 © 2020 4th motion GmbH。 根据 MIT 许可 发布。

@4th-motion/git-hooks

Easy to set up git hooks that can be shared between your projects.

Version License

Handle all your git hooks in one place and share them between your projects. Changes can be made at any time - old configurations are automatically overwritten because there's only one source of truth.


Terminal


Installation

Add this package as a devDependency to your project:

yarn add --dev @4th-motion/git-hooks


Usage

Once the package is installed, you can initiate it with:

yarn 4th-git-hooks

Now you can specify the tasks to be performed on a particular hook. The tasks must be present in the script field in package.json.

{
  "git": {
    "pre-commit": ["lint", "test"]
  }
}

Note that the commit-msg hook is always executed. This ensures that commits can only be pushed with certain keywords (e.g. feat, fix, …) and never to the master branch. If you do not want to activate this hook, just remove it from the hooks/ folder.


Behind the scenes

The initialization process extends the package.json file as follows:

{
  "scripts": {
    "postinstall": "4th-git-hooks"
  }
}

This will copy all git-hooks from the hooks/ directory during each installation. You can always edit existing hooks or add new hooks. A list off all git hooks can be found here.


Further documents


Related projects

@4th-motion/eslint-config@4th-motion/stylelint-config
@4th-motion/eslint-config@4th-motion/stylelint-config


License

Copyright © 2020 by 4th motion GmbH. Released under the MIT License.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文