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.

[Git] Automatically running tests before commits with ghooks的更多相关文章

  1. appium(3)-Running Tests

    Running Tests   Preparing your app for test (iOS) Test apps run on the simulator have to be compiled ...

  2. [React Testing] Setting up dependencies && Running tests

    To write tests for our React code, we need to first install some libraries for running tests and wri ...

  3. Running tests on PyCharm using Robot Framework

    问题: I started using PyCharm with the robot framework, but i'm facing an issue. how can i run my test ...

  4. [Git] Squash all of my commits into a single one and merge into master

    Often you have your feature branch you’ve been working on and once it’s ready, you just want it to m ...

  5. [Protractor] Running tests on multiple browsers

    Testing your AngularJS application on multiple browsers is important, and Protractor offers this abi ...

  6. 转:VS2010调试NUnit测试项目 (Running or debugging NUnit tests from Visual Studio without any extensions)

    If you write unit tests and use NUnit test framework this may be helpful. I decided to write this si ...

  7. Pro Git - 笔记3

    Git Branching Branches in a Nutshell Branches in a Nutshell let’s assume that you have a directory c ...

  8. Pro Git - 笔记2

    Git Basics Getting a Git Repository Initializing a Repository in an Existing Directory For Linux: $ ...

  9. Git - Tutorial [Lars Vogel]

    From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...

随机推荐

  1. Android Design Support Library: 学习CoordinatorLayout

    简述 CoordinatorLayout字面意思是"协调器布局",它是Design Support Library中提供的一个超级帧布局,帮助我们实现Material Design ...

  2. Entity Framework 新增实体,新增抽象实体

    抽象实体不能new 抽象类:人,实体类:学生 人 p_人= new 学生();   添加数据,学生和人都添加 抽象类可以提供一个抽象的方法,但是并没有实现,类似接口,但又不同于接口.子类继承父类时必须 ...

  3. access 2007 vba (亖)

    OpenReport方法执行 OpenReport 操作在 Visual Basic 中. 语法   表达式 .OpenReport(ReportName, View, FilterName, Whe ...

  4. 东软实训1 -jsp内置对象及其常用方法

    JSP 的内置对象及方法详细说明 一. request 对象 客户端的请求信息被封装在 request 对象中,通过它才能了解到客户的需 求,然后做出响应.它是 HttpServletRequest ...

  5. print流

    PrintWriter和PrintStream都属于输出流,分别针对字符和字节. PrintWriter和PrintStream提供了重载的print,println方法用于多种类型的输出 Print ...

  6. javascript关于检测浏览器和操作系统的问题

    1.方法学: 最好是检测浏览器的最小版本,这样才不会当版本升级之后不断添加新的内容进去. 理想的方式: if(isMinIE5){ //code } 直接检查准确的版本的缺点: if(isMinIE5 ...

  7. 百度touch的手势框架,touch.js

    今天,随便搜搜看到了一个新的手势库,也许能让我为现在使用者的hammer.js的手势库带来的烦恼而消除. 它是百度团队开发的,现在由百度云Clouda进行维护. 官网   http://touch.c ...

  8. CentOS下安装postgresql

    一.说明 postgresql版本:9.4.1 安装包: postgresql94-server-9.4.1-1PGDG.rhel6.x86_64.rpm postgresql94-libs-9.4. ...

  9. hdu 2079 选课时间(题目已修改,注意读题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...

  10. [LeetCode 116 117] - 填充每一个节点的指向右边邻居的指针I & II (Populating Next Right Pointers in Each Node I & II)

    问题 给出如下结构的二叉树: struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } ...