Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

feat(cli): Allow validate from text #71

Conversation

maxcnunes
Copy link
Contributor

With this approach makes easier validate commit messages through a text instead of only accepting
validation through files.

With this approach makes easier validate commit messages through a text instead of only accepting
validation through files.
@codecov-io
Copy link

codecov-io commented Mar 31, 2017

Codecov Report

Merging #71 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #71   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         123    123           
=====================================
  Hits          123    123

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c4aee9...007fa5d. Read the comment docs.

Copy link
Collaborator

@spirosikmd spirosikmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your PR! Some comments from me.

lib/cli.js Outdated

function getCommitMessage(buffer) {
return hasToString(buffer) && buffer.toString();
fs.stat(commitMsgFileOrText, function(err, stat) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you use fs.stat here to check existence of the file. This is not recommended by node docs. You could use fs.readFile and if there is an ENOENT error execute validate(commitMsgFileOrText, false);. Would this work?


var commitMsgFile = process.argv[2] || getGitFolder() + '/COMMIT_EDITMSG';
var incorrectLogFile = commitMsgFile.replace('COMMIT_EDITMSG', 'logs/incorrect-commit-msgs');
var bufferToString = function (buffer) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could turn these anonymous function expressions to named function expressions. Usually anonymous functions are annoying during debugging 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By setting a function to a variable it will be named after that variable. So doing something like this one below is redundant:

var bufferToString = function bufferToString(buffer) {

Since in case the file exists we will read it. Makes more sense use directly fs.readFile.
Copy link
Collaborator

@spirosikmd spirosikmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 🎉

@kentcdodds kentcdodds merged commit eefe5f3 into conventional-changelog-archived-repos:master Mar 31, 2017
@kentcdodds
Copy link
Collaborator

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants