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. AppCanCSS背景图片的属性

    最近在用AppCan框架技术做跨平台移动应用开发,碰到界面布局设计中图片平铺.拉伸效果. 我们用到的是CSS 3中Background-size属性. 网上查了下这个属性,小记下: 取值: backg ...

  2. Android开发手记(7) 按钮类控件的使用

    1.点击Button改变页面背景色 通过Button改变页面背景色,首先新建相应的对象,让后绑定到Layout上的元素. final RelativeLayout layout = (Relative ...

  3. csms发布步骤

    1.wcf发布 通过点击 CSMS2.Application,右键发布按钮,将文件拷贝 2.打包文件 CSMS2.Resources 中 update.config 修改为对应 ServerUrl地址 ...

  4. 修改SELinux设置,使vsftp在enforcing security enhance模式下正常运行

    开了SELinux和防火墙,没想到引出了vsftp的问题.FTP登录报错:500 OOPS: cannot change directory.下面来看看产生这个问题的原因和对策. 首先,分析一下冲突原 ...

  5. 单点登录CAS使用记(四):为登录页面加上验证码

    CAS默认的登录页面样式如下,只有用户名与密码两项验证项目. 现在需要为首页登录加上验证码功能. 第一步:首页对默认登录页面的样式进行了调整,使其看上去还算美观. 在页面上加上了验证码项目. 第二步: ...

  6. jsp连接MySQL操作GIS地图数据,实现添加point的功能

    index_map.jsp中的代码: <%@ page language="java" pageEncoding="utf-8"%> <%@ ...

  7. phpcms二次开发步骤

    文件目录结构 根目录 | – api 接口文件目录 | – caches 缓存文件目录 | – configs 系统配置文件目录 | – caches_* 系统缓存目录 | – phpcms phpc ...

  8. 制作PHP安装程序的原理和步骤56

    制作PHP安装程序的原理和步骤56 1.制作PHP安装程序的原理和步骤检查目录或文件的权限----修改或填加配置文件---检查配置文件正 确性---导入数据库----锁定或删除安装文件 原理: 其实P ...

  9. htmlspecialchars()函数

    htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体. 预定义的字符是: & (和号) 成为 & " (双引号) 成为 " ' (单引 ...

  10. 【结构型】Adapter模式

    Adapter模式主要意图是将类或接口转换成客户期望的接口,从而使得原本不兼容.无法在一起工作的接口可以在一起工作.该模式有两种形式的Adapter法,一是继承方式:二是对象关联依赖方式. 继承方式A ...