zoukankan      html  css  js  c++  java
  • [Git] Automatically running tests before commits with ghooks

    Wouldn't it be nice if everyone ran the tests before committing code? With ghooks, you can automatically add a githook when dependencies are installed which will allow you to define common scripts to be run at various points during git actions (like committing). In this lesson, we'll add a githook for running the tests before we commit code to make sure we don't commit anything that breaks the tests.

    Install:

    npm i -D ghooks cross-env

    [Notic]: cross-env is a package which enable you write Linux/mac scripts in your package.json and the same script can also run on Windows machine.

    Config:

    // package.json
    
        "config": {
            "ghooks": {
                "pre-commit": "npm run test:single",
                "post-merge": "npm install"
            }
        }

    So before commit , it runs tests first and after merged, run npm install.

  • 相关阅读:
    2021-5-14 日报博客
    2021-5-13 日报博客
    2021-5-11 日报博客
    2021-5-10 日报博客
    2021-5-8 周报博客
    团队介绍——北部大队
    周总结4
    梦断代码阅读笔记02
    周总结3
    周总结2
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5366298.html
Copyright © 2011-2022 走看看