-
Notifications
You must be signed in to change notification settings - Fork 9
Huge changes #2
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
Huge changes #2
Conversation
|
Wow! This looks amazing! Thanks! I will have a look and get back to you BUT this PR will be accepted! |
.travis.yml
Outdated
|
|
||
| node_js: | ||
| - 6 | ||
| - 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to use v4 and v6? I mean, we are going to use the same version of eslint regardless of node version, right? So if it works in v6 it is going to work in v4 and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but as 4.x is LTS, testing on it is to be sure that we support this LTS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but eslint will check the file statically without ever executing any code so even if eslint is running under node 4.x and returning that the code is flawless does not necessarily mean that it will work for v4.x.
What we really want is something like: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unsupported-features.md
.travis.yml
Outdated
| - npm install -g eslint | ||
|
|
||
| install: | ||
| - npm install --only=production |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you added a yarn.lock file, we should use yarn and according to this blog post: https://blog.travis-ci.com/2016-11-21-travis-ci-now-supports-yarn travis will always use yarn if there is a yarn.lock and we don't override the install script. So I think we should replace the command with yarn install --production.
LICENSE
Outdated
| @@ -0,0 +1,21 @@ | |||
| MIT License | |||
|
|
|||
| Copyright (c) 2016 Oskar Karlsson | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add your name here. Eg, Oskar Karlsson, Mathieu Santo Stefano--Féron
| # Gitmoji-commit-hook | ||
|
|
||
| > Add emoji to your commits | ||
| [](https://travis-ci.org/welcoMattic/gitmoji-commit-hook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update all paths after the merge. I can fix that.
package.json
Outdated
| "description": "Start the commit message with an applicable emoji", | ||
| "main": "index.js", | ||
| "name": "gitmoji-commit-hook", | ||
| "version": "1.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should bump the version to 2.0.0 since the tool now requirer a internet connection AND do not ask for a issue number any more.
bin/index.js
Outdated
| } | ||
| }); | ||
|
|
||
| fs.chmod(`${path}/prepare-commit-msg`, '755', (err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can this even work 😉. You call fs.writeFile which will create a file asynchronous but at the same time you will try to change the chmod. It works but I can't say why. I would have called fs.chmod in the callback of fs.writeFile.
| console.error(chalk.red('🚨 ERROR: The directory is not a git repository.')); | ||
| } | ||
| } else { | ||
| axios.get(gitmojis) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cache the file so we don't are dependent of internet when we are going to commit. I'm thinking of something like this:
1. check if gitmojis.json exist on disk
a. if it exist, use it but if the file is older than 3 days: try to download a new file in the background.
b. if it don't exist, download the file and use it.
I will create a issue so we can fix this in the feature. We don't need to fix this now.
| name: gitmoji.emoji + ' ' + gitmoji.description, | ||
| value: gitmoji.emoji | ||
| }; | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have removed the question about reference issue number. Was that intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like KISS principle, so our hook aim is to add emoji to commit message. As gitmoji-cli allows to add issue number, commit title, commit message etc ... I think we dont need to ask for issue number anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Far enough.
bin/index.js
Outdated
| }); | ||
|
|
||
| if(/COMMIT_EDITMSG/g.test(process.argv[2])) { | ||
| inquirer.prompt(questions).then((answers) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should return inquirer.prompt so we can catch (line 59) any errors that inquirer might give.
bin/index.js
Outdated
| } | ||
| }) | ||
| .catch(err => { | ||
| console.log(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use console.error(chalk.red('🚨 ERROR: ${err}.'));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of creating a error-handler method. eg.
const errorHandler = error => {
console.error(chalk.red(`🚨 ERROR: ${error}`));
process.exit(1);
};So we can handel all error message in the same manner.
|
Looking good. I just have a few question, see above. |
|
@tjoskar I just fix things after your feedback, thank you for it! |
|
@welcoMattic, great but I still thinks we need to check if the file exists before we override the content, see #2 (comment) Something like this: if (process.argv[2] === '--init') {
if (!pathExists.sync('.git')) {
errorHandler('The directory is not a git repository.');
}
if (fileExists(${path}/prepare-commit-msg)) {
errorHandler(`A prepare-commit hook already exists, please remove the hook (rm .git/hooks/prepare-commit-msg) or install gitmoji-commit-hook manually by adding the following content info ${${path}/prepare-commit-msg}: \nexec < /dev/tty\ngitmoji-commit-hook $1`);
}
fs.writeFile(${path}/prepare-commit-msg, `#!/bin/sh\nexec < /dev/tty\ngitmoji-commit-hook $1`, (err) => {
if (err) {
errorHandler(err);
} else {
fs.chmod(${path}/prepare-commit-msg, '755', (err) => {
if (err) {
errorHandler(err);
} else {
console.log(`${chalk.green('🎉 SUCCESS 🎉')} gitmoji-commit-hook initialized with success.`);
}
});
}
});
} else {
axios.get(gitmojis)
...Or what do you think? |
|
@tjoskar Done ;) |
Ref. #3