carloscuesta / gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻
https://www.npmjs.com/package/gitmoji-cli
MIT License
4.63k stars 206 forks source link

gitmoji init won't a the hook if the parent directory does not exists #81

Closed dancerphil closed 6 years ago

dancerphil commented 6 years ago

Hello @carloscuesta!

When run gitmoji -i, I got ERROR: Error: ENOENT: no such file or directory, open 'xxxxxx/.git/hooks/prepare-commit-msg'

And gitmoji commit hook created successfully.

But actually, the hook is not created.

If /.git/hook dir not exist, bug happens.

OS: macOS Sierra gitmoji-cli -v: 1.8.4 Node version: 8.2.1 Error Message:

ERROR: Error: ENOENT: no such file or directory, open '/Users/me/Desktop/g/gitmoji-cli/.git/hooks/prepare-commit-msg' gitmoji commit hook created successfully.

carloscuesta commented 6 years ago

Hey @dancerphil

As far as I know, it's a standard the hooks directory that lives under ./git/hooks/ when you create a git repo.

Edit: I understand now, when the hooks folder doesn't exists, the fs.writeFile can't create the file because the parent directory is not available.

For curiosity's sake, did you removed the hooks folder? Or you just cloned the repo and the .git directory wasn't containing that folder? Are you using a git ui software or something like that? Or just using git from the command line?