Skip to content

feat(core): Allow to configure with json, yaml and package.json #74

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

Closed
wants to merge 1 commit into from

Conversation

pvdlg
Copy link

@pvdlg pvdlg commented Sep 17, 2017

Fix #73

@pvdlg pvdlg force-pushed the cosmiconfig branch 2 times, most recently from c2cbabf to 8bc87e4 Compare September 17, 2017 22:53
Copy link
Contributor

@marionebl marionebl left a comment

Choose a reason for hiding this comment

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

Thanks a lot - Great work! I have two comments on the changes to file, could you have a look?

const explorer = cosmiconfig('commitlint', {
rcExtensions: true,
sync: true,
stopDir: process.cwd()
Copy link
Contributor

Choose a reason for hiding this comment

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

cosmiconfig reintroduces find-up mechanics - I think the current git root would be more appropriate as stopDir.

I'd also prefer using this in the async variant. Making file async and awaiting explorer.load should make that a breeze.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, but how can I obtain the git root ? Also what if the project is not a git repo ?

I will make the change for using async, but we'll have to set the tests for load in serial as they change the current dir.

@pvdlg
Copy link
Author

pvdlg commented Sep 19, 2017

I changed the code to use the async function of cosmiconfig. I also add to set the load tests as serial.
You mentioned setting stopDir as the git root. But I don't know how to obtain the git root, and I'm not sure how to handle the case where the project is not a git repo. Any suggestions @marionebl ?

@marionebl
Copy link
Contributor

marionebl commented Sep 20, 2017

An example on how to find the git root can be found in core/read.js#74.

Given commitlint assumes a cwd that is inside a git repository I think it would be good to throw a instructive error message if we detect we are not inside one. The current implementation detects that by checking if the return value is a string.

I think it is fine if you just copy the relevant implementation for the time being, I'll move that to a separate package eventually

@pvdlg
Copy link
Author

pvdlg commented Sep 20, 2017

Ok but that mean I need a .git directory in each fixtures subdirectory for the test to work.
And .git directory are excluded with .gitignore.

The other solution is to create a git repo in a temp directory for each test and copy the content of the fixture subdirectory in it. But that's a lot of changes in the load.test.js file.
What do you prefer ?

@marionebl
Copy link
Contributor

Option 2 sounds good

@pvdlg
Copy link
Author

pvdlg commented Sep 20, 2017

Ok I'll have to copy the whole content, recursively, of each fixture sub-folder into the temp git repo.
Do you have an util function to do that ? (I can't find one).
Otherwise I could use https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy.md

@marionebl
Copy link
Contributor

The cli package uses sander for fs stuff – you are looking for sander.copydir

@pvdlg
Copy link
Author

pvdlg commented Sep 20, 2017

I made the changes.
I had to duplicate initRepository, cleanRepository and rand which is not ideal.
Ideally we should extract those in a module. Normally ava helpers would go to test/helpers directory. But as your structure is not standard and require ava custom config path, I'm not sure where to put those test helpers.

Let me know where to put them and if you want me to do that.

@pvdlg pvdlg force-pushed the cosmiconfig branch 3 times, most recently from 2dcc27f to 927b4f8 Compare September 21, 2017 00:27
@marionebl
Copy link
Contributor

Looks good, thanks. I'll handle the dedupe at some later time. I am on vacation till 3th Oct, will make an effort to merge it then!

@marionebl
Copy link
Contributor

Moving this to #83

@marionebl marionebl closed this Oct 3, 2017
@marionebl
Copy link
Contributor

Landed, thank you!

@marionebl
Copy link
Contributor

Published with v4.0.0 🚀

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

Successfully merging this pull request may close these issues.

2 participants