Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit hook fails for unknown reason #155

Closed
sudo-suhas opened this issue Aug 13, 2017 · 8 comments
Closed

pre-commit hook fails for unknown reason #155

sudo-suhas opened this issue Aug 13, 2017 · 8 comments

Comments

@sudo-suhas
Copy link
Collaborator

sudo-suhas commented Aug 13, 2017

  • nps version: 5.7.0
  • node version: 8.2.1
  • npm version: 5.3.0
  • yarn version: 0.27.5

Scripts file (or at least the relevant bits):

{
  "scripts": {
    "commitmsg": "opt --in commit-msg --exec \"validate-commit-msg\"",
    "precommit": "lint-staged && opt --in pre-commit --exec \"npm start validate\""
  }
}

The command executed:

$ cat .opt-in
commit-msg
pre-commit

$ touch test-precommit.txt && git add test-precommit.txt

$ git commit

> husky - npm run -s precommit
> husky - node v8.2.1

25l[08:43:26] Running tasks for *.js [started]
[08:43:27] Running tasks for *.js [skipped]
[08:43:27] → No staged files match *.js
25h25h
> husky - pre-commit hook failed (add --no-verify to bypass)
> husky - to debug, use 'npm run precommit'

$ yarn run precommit
yarn run v0.27.5
$ lint-staged && opt --in pre-commit --exec "npm start validate"
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js

> cross-env@5.0.0-beta.0 start E:\Projects\repos\cross-env
> nps "validate"

nps is executing `validate` : node node_modules\concurrently\src\main.js --kill-others-on-fail --prefix-colors "bgBlue.bold,bgMagenta.bold,bgGreen.bold" --prefix "[{name}]" --names "lint,build,test" "nps lint" "nps build" "nps test"
[test] nps is executing `test` : jest --coverage
[build] nps is executing `build` : node node_modules\rimraf\bin.js dist && babel --copy-files --out-dir dist --ignore *.test.js src
[lint] nps is executing `lint` : eslint .
[build] src\bin\cross-env-shell.js -> dist\bin\cross-env-shell.js
[build] src\bin\cross-env.js -> dist\bin\cross-env.js
[build] src\command.js -> dist\command.js
[build] src\index.js -> dist\index.js
[build] src\variable.js -> dist\variable.js
[build] nps build exited with code 0
[lint] nps lint exited with code 0
[test]  PASS  src\index.test.js
[test]  PASS  src\command.test.js
[test]  PASS  src\variable.test.js
[test] -------------|----------|----------|----------|----------|----------------|
[test] File         |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
[test] -------------|----------|----------|----------|----------|----------------|
[test] All files    |      100 |      100 |      100 |      100 |                |
[test]  command.js  |      100 |      100 |      100 |      100 |                |
[test]  index.js    |      100 |      100 |      100 |      100 |                |
[test]  variable.js |      100 |      100 |      100 |      100 |                |
[test] -------------|----------|----------|----------|----------|----------------|
[test]
[test] Test Suites: 3 passed, 3 total
[test] Tests:       40 passed, 40 total
[test] Snapshots:   0 total
[test] Time:        2.55s
[test] Ran all test suites.
[test] nps test exited with code 0
Done in 14.94s.

Problem description:
I faced this issue while trying to contribute to cross-env. While manual execution of the precommit npm script did not return an error, the pre-commit hook failed unexpectedly.

Suggested solution:
Not sure.

More info:

$ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
@kentcdodds
Copy link
Collaborator

Hmmm... Nothing in the output you pasted indicates the script failed. Was there any error output?

@sudo-suhas
Copy link
Collaborator Author

Nope.

@kentcdodds
Copy link
Collaborator

Huh, I'm not sure what's going on there, but I'm guessing it's not an nps issue specifically. Probably something to do with the scripts that are being run. Could you dig a little deeper? Thanks!

@sudo-suhas
Copy link
Collaborator Author

@kentcdodds I am going to need a bit more to go on. I have used husky in other projects without any issues. The actual npm script does not return error status code. The only other moving part involved is nps.

@kentcdodds
Copy link
Collaborator

I'm afraid that I don't have a lot of time to dedicate to this issue right now :-( Sorry

@sudo-suhas
Copy link
Collaborator Author

No problem. If you can find some time later to point me in the right direction, I'd be happy to help fix this issue.

@sudo-suhas
Copy link
Collaborator Author

@kentcdodds I dug little bit more and it turns out this wasn't an issue with nps after all. Created a PR ta2edchimp/opt-cli#213 which can fix this.

@kentcdodds
Copy link
Collaborator

Great! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants