-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: More config file options #383
Conversation
Previously, the config service would mutate the default config object if a config file could not be found. This caused a test to pass since the given argument then mutated the default config object.
@@ -43,9 +43,6 @@ jobs: | |||
- run: | |||
name: Upload command test | |||
command: yarn test-upload-command | |||
- run: | |||
name: Setup integration test .percy.yml | |||
command: mv .ci.percy.yml .percy.yml |
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.
🧹🎉
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.
🏁 Very nice, next task is to update the docs and reach out to the folks who asked for .env support 😃
config: flags.string({ | ||
char: 'c', | ||
description: 'Path to percy config file', | ||
}), |
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.
👏 🔥
# [0.17.0](v0.16.2...v0.17.0) (2019-10-01) ### Features * ✨ More config file options ([#383](#383)) ([b9875a1](b9875a1))
Purpose
In part of making the configuration experience better by auto-loading
.env
files in percy-client, we can also expand.percy.yml
support in agent to encompass more file types and use hierarchical priority!Approach
Uses cosmiconfig to search for various
.percy.*
config files and auto-loads said configuration. The library will start its search for the filenames in the current working directory and recurse upwards until a match is found.There is also an option to load a specific config file by passing in a filename to the
loadSync
method. So targeted configs can become possible by allowing a flag to provide a filepath. I added this option under a--config
flag and removed the Circle step to manually rename the.ci.percy.yml
file.I noticed the previous configurations service mutated the
DEFAULT_CONFIGURATION
object which causes a false positive test. I took this as an opportunity to improve how configuration is handled, and made it into a pure functional util. For flags and args parsing: instead of a multitude ofif
statements, a map is used and undefined values are filtered out.percy-client
was updated to include.env
support. Also of note is cosmiconfig was already a subdependency, so there was no overhead adding it as our own dependency.