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:

  1. 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:

  1. // package.json
  2.  
  3. "config": {
  4. "ghooks": {
  5. "pre-commit": "npm run test:single",
  6. "post-merge": "npm install"
  7. }
  8. }

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. Cookies欺骗分析与防护

    今天来谈谈cookies欺骗是怎么回事以及如何避免. 用户在登录之后通常会保存用户信息,以便在其他需要权限的页面去验证用户信息是否具有访问权限. 有同学说我在登录的时候已经很注意SQL注入问题了,还有 ...

  2. Regex.Escape

    C# 字符串变量str 的值为"a\nb"如果直接输出显示的话,就成了:ab需要输出显示为:a\nb问,怎么办?千万别告诉我定义: str=@"a\nb",因为 ...

  3. Linux ulimit 系统资源控制

    ulimit 的功能和用法 ulimit 功能简述 假设有这样一种情况,当一台 Linux 主机上同时登陆了 10 个人,在系统资源无限制的情况下,这 10 个用户同时打开了 500 个文档,而假设每 ...

  4. iOS 网络与多线程--8.百度地图的使用(调用系统浏览器)

    通过调用设备自带的浏览器,打开百度地图 // 1.定义一个方法,用来打开谷歌地图的功能 -(IBAction)openMaps { // 2.定义一个字符串,作为百度地图的当前地理位置 废弃 NSSt ...

  5. 【C++学习之路】派生类的构造函数(二)

    二.有内嵌对象的派生类 1.一般来说,我们会这样定义构造函数 student( int i, string nam, int pid, string pnam, int sid) : person( ...

  6. Rational Rose 7.0的使用(转)

    1.Rose如何隐藏类的属性和操作? 右击类图,选择Options->Suppress Attributes/Suppress Operations 2.Rose中如何表示双向关联? 右击关联线 ...

  7. view ondraw

    窗口发生重绘时会被应用程序的窗口框架给调用 要使输出的东西始终能在窗口中看到 就可以使用该函数  窗口从到有的时候就会产生WM_PAINT消息,让窗口发生重绘 这是程序就会执行到ONDRAW函数处 所 ...

  8. javascript模块

    //使用模块 template = {}; template.createObj = (function(){ //私有成员 var _age = ""; var _name = ...

  9. Linux定时任务crontab命令使用详解

    1.crontab功能介绍: crontab的功能是在一定的时间间隔内定时执行一些命令. 2.crontab参数详解: 1 crontab -u //设定某个用户的cron服务,一般root用户在执行 ...

  10. .NET MVC插件化开发(支持Script和css压缩)

    上一篇博文里面,没有支持Script和css的压缩功能以及script和css的路径问题也没有解决,所以重新发布一个版本,解决了这几个问题,并且优化了插件路由注册,现在可以很方便的实现热插拔web插件 ...