Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

precommit hook husky guide #231

Closed
gruppjo opened this issue Aug 20, 2015 · 2 comments
Closed

precommit hook husky guide #231

gruppjo opened this issue Aug 20, 2015 · 2 comments

Comments

@gruppjo
Copy link
Contributor

gruppjo commented Aug 20, 2015

package.json

"scripts": {
    "precommit": "gulp linting-throw"
 }

npm install husky --save-dev
https://github.com/typicode/husky

see #23 for further details

@MathiasTim
Copy link
Contributor

I just tried adding a precommit hook with husky for the newest version of the demo repo.

I thought besides linting I'll add tests as well.

  "scripts": {
    "precommit": "gulp linting-throw && gulp karma && gulp protractor"
  },

But somehow if there is an error with tests (gulp karma) an error occurs and the task stops. Also occurs when just running gulp karma. Log below.

Also the fact, that linting will run multiple times is not nice, but necessary I guess. Because we have to run gulp linting-throw

Another Problem seems to be, that either gulp protractor nor gulp protractor-build seems to stop on their own, so husky will never know if the build passed and it can be committed.

$ git commit -am 'asd'
[13:09:36] Using gulpfile ~/Projects/test/generator-m-demo/gulpfile.js
[13:09:36] Starting 'eslint'...
[13:09:37] Starting 'jsonlint-throw'...
[13:09:38] Finished 'jsonlint-throw' after 522 ms
[13:09:38] 
/Users/mathiasmaier/Projects/test/generator-m-demo/app/main/controllers/blubb-ctrl.js
  5:8  error  Unexpected space between function name and paren  no-spaced-func

✖ 1 problem (1 error, 0 warnings)

[13:09:38] Finished 'eslint' after 1.58 s
[13:09:38] Starting 'linting-throw'...
[13:09:38] Finished 'linting-throw' after 13 μs
[13:09:40] Using gulpfile ~/Projects/test/generator-m-demo/gulpfile.js
[13:09:40] Starting 'eslint'...
[13:09:40] Starting 'jsonlint'...
[13:09:41] Finished 'jsonlint' after 441 ms
[13:09:41] 
/Users/mathiasmaier/Projects/test/generator-m-demo/app/main/controllers/blubb-ctrl.js
  5:8  error  Unexpected space between function name and paren  no-spaced-func

✖ 1 problem (1 error, 0 warnings)

[13:09:41] Finished 'eslint' after 1.3 s
[13:09:41] Starting 'linting'...
[13:09:41] Finished 'linting' after 12 μs
[13:09:41] Starting 'karma'...
05 09 2015 13:09:42.148:INFO [karma]: Karma v0.13.9 server started at http://localhost:9876/
05 09 2015 13:09:42.157:INFO [launcher]: Starting browser PhantomJS
05 09 2015 13:09:43.198:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket 5v3KbzW6Unelcv2WAAAA with id 85210177
PhantomJS 1.9.8 (Mac OS X 0.0.0) module: main, controller: DebugCtrl .grade() should classify asdfasdfasdf as strong FAILED
    Expected 'strongs' to equal 'strong'.
        at /Users/mathiasmaier/Projects/test/generator-m-demo/test/karma/main/debug-ctrl.spec.js:33
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 10 of 10 (1 FAILED) (0.006 secs / 0.08 secs)
[13:09:43] 'karma' errored after 1.67 s
[13:09:43] Error: 1
    at formatError (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:107:17)
    at Gulp.Orchestrator._emitTaskDone (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at removeAllListeners (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/karma/lib/server.js:325:7)
    at Server.<anonymous> (/Users/mathiasmaier/Projects/test/generator-m-demo/node_modules/karma/lib/server.js:336:9)
    at Server.g (events.js:199:16)
    at Server.emit (events.js:129:20)
    at net.js:1409:10
    at process._tickCallback (node.js:355:11)

husky - pre-commit hook failed (add --no-verify to bypass)

Protractor not finishing:
screen shot 2015-09-05 at 13 18 17

@gruppjo gruppjo modified the milestones: 1.3.0, 1.4.0 Sep 7, 2015
@gruppjo gruppjo modified the milestones: 1.4.0, 1.5.0 Nov 3, 2015
@gruppjo gruppjo removed this from the 1.5.0 milestone Dec 21, 2015
@gruppjo gruppjo added this to the 1.9.0 milestone Jun 6, 2016
@gruppjo gruppjo changed the title provide recipe for git hooks precommit hook husky guide Jun 6, 2016
@gruppjo
Copy link
Contributor Author

gruppjo commented Jun 6, 2016

gruppjo added a commit that referenced this issue Jun 9, 2016
@gruppjo gruppjo closed this as completed Jun 9, 2016
gruppjo added a commit that referenced this issue Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants