Add ability to use absolute config path #59
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, Absolutely loving this linter!
Description
I've come across the need to have an absolute path for my config file, which doesn't currently work as the
process.cwd()
gets automatically prepended to the config path.Ideal usage:
stylint foo.styl -c /Users/jack/.stylintrc
Solution
This pull request adds a check to see if the specified config path is absolute. If it is, it uses it exactly as supplied. If it's not, it continues to use the code you had in place already.
In future, it might be nice to use node's path.isAbsolute(), but as it was only just released with node 0.12, I went with something more backwards compatible.
Tests
I've not added a test for this, as your existing config tests have an outstanding
@TODO
comment. Wasn't sure whether you'd like to own that, or if you want me to give it a go. The existing tests still pass as expected.Justification
I'm putting together a SublimeLinter Stylint plugin which allows for 'live' linting. Like jshint, it traverses up the directory tree to find a config file, then supplies its absolute path to Stylint. Early days, but happy to collaborate once I've progressed a little further if you'd like.