husky
Advanced tools
Comparing version 0.13.3 to 0.13.4
# CHANGELOG | ||
## 0.13.3 | ||
* Revert `Fixes issue with OS X + brew where nvm was loaded even when npm was already present` that was introduced in `v0.13.0` as it was preventing Husky to load `nvm` in some cases [#106](https://github.com/typicode/husky/issues/106) | ||
## 0.13.2 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "husky", | ||
"version": "0.13.3", | ||
"version": "0.13.4", | ||
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -41,3 +41,3 @@ # husky [![](http://img.shields.io/npm/dm/husky.svg?style=flat)](https://www.npmjs.org/package/husky) [![npm version](https://badge.fury.io/js/husky.svg)](https://www.npmjs.com/package/husky) [![Build Status](https://travis-ci.org/typicode/husky.svg?branch=master)](https://travis-ci.org/typicode/husky) | ||
* [Hotel](https://github.com/typicode/hotel) | ||
* ... and more than 2600+ [other awesome projects](https://libraries.io/npm/husky/dependent-repositories). | ||
* ... and almost 4000 [other awesome projects](https://libraries.io/npm/husky/dependent-repositories). | ||
@@ -64,6 +64,10 @@ ## Uninstall | ||
If you've installed Node using the [standard installer](https://nodejs.org/en/), [nvm](https://github.com/creationix/nvm) or [homebrew](http://brew.sh/), git hooks will be executed even in GUI applications. | ||
If you've installed Node using the [standard installer](https://nodejs.org/en/), [nvm](https://github.com/creationix/nvm) or [homebrew](http://brew.sh/), Git hooks will be executed in GUI applications. | ||
In the case of [`nvm`](https://github.com/creationix/nvm), husky will try to use the `default` installed version or use the project `.nvmrc`. | ||
### Working with multiple version of Node | ||
If [`nvm`](https://github.com/creationix/nvm) is installed, husky will try to use the `default`/`current` installed Node version or use the project `.nvmrc`. | ||
__Tip__ to use the system-installed version of node, `nvm` provides a [`system`](https://github.com/creationix/nvm#system-version-of-node) alias | ||
### Accessing Git params | ||
@@ -91,5 +95,5 @@ | ||
### Yarn | ||
### Yarn support | ||
For Yarn, you currently need to pass `--force` to be sure that hooks are going to be installed (`yarn add husky --dev --force`). You can also manually install hooks using `node node_modules/husky/bin/install`. | ||
Please use `yarn` `v0.24+` | ||
@@ -96,0 +100,0 @@ </details> |
@@ -8,2 +8,7 @@ var fs = require('fs') | ||
var SKIP = 'SKIP' | ||
var UPDATE = 'UPDATE' | ||
var MIGRATE = 'MIGRATE' | ||
var CREATE = 'CREATE' | ||
function write (filename, data) { | ||
@@ -47,3 +52,3 @@ fs.writeFileSync(filename, data) | ||
function getHookScript (hookName, relativePath, cmd) { | ||
// On Windows normalize path (i.e. convert \ to /) | ||
// On Windows normalize path (i.e. convert \ to /) | ||
var normalizedPath = normalize(relativePath) | ||
@@ -138,2 +143,3 @@ | ||
'echo "> husky - npm run -s ' + cmd + '"', | ||
'echo "> husky - node `node -v`"', | ||
'echo', | ||
@@ -175,15 +181,17 @@ '', | ||
if (!fs.existsSync(filename)) { | ||
return write(filename, hookScript) | ||
write(filename, hookScript) | ||
return CREATE | ||
} | ||
if (isGhooks(filename)) { | ||
console.log('migrating ghooks ' + hookName + ' script') | ||
return write(filename, hookScript) | ||
write(filename, hookScript) | ||
return MIGRATE | ||
} | ||
if (isHusky(filename)) { | ||
return write(filename, hookScript) | ||
write(filename, hookScript) | ||
return UPDATE | ||
} | ||
console.log('skipping ' + hookName + ' hook (existing user hook)') | ||
return SKIP | ||
} | ||
@@ -212,6 +220,26 @@ | ||
if (hooksDir) { | ||
hooks.forEach(function (hookName) { | ||
var npmScriptName = hookName.replace(/-/g, '') | ||
createHook(huskyDir, hooksDir, hookName, npmScriptName) | ||
}) | ||
hooks | ||
.map(function (hookName) { | ||
var npmScriptName = hookName.replace(/-/g, '') | ||
return { | ||
hookName: hookName, | ||
action: createHook(huskyDir, hooksDir, hookName, npmScriptName) | ||
} | ||
}) | ||
.forEach(function (item) { | ||
switch (item.action) { | ||
case MIGRATE: | ||
console.log('migrating ghooks ' + item.hookName + ' script') | ||
break | ||
case UPDATE: | ||
break | ||
case SKIP: | ||
console.log('skipping ' + item.hookName + ' hook (existing user hook)') | ||
break | ||
case CREATE: | ||
break | ||
default: | ||
console.error('Unknown action') | ||
} | ||
}) | ||
console.log('done\n') | ||
@@ -218,0 +246,0 @@ } else { |
Sorry, the diff of this file is not supported yet
106
2
14735
10
265