macbre / phantomas

Headless Chromium-based web performance metrics collector and monitoring tool

Home Page:https://www.npmjs.com/package/phantomas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle environment variables in YAML config files

rbayliss opened this issue · comments

It would be a really great feature to have the base URL be separate from the URL of the test. The main use case for this is in having a single config file that you want to run on multiple environments of a site. In my config file, I'd like to be able to say:

url: /my-page

Then on the command line, be able to set the base with something like:

phantomas --config=my-config.yaml --base-url=http://foo.com

Is this implemented, or possible? I'm happy to help out with a PR here, but I'm not sure where to start.

@rbayliss, great suggestion 👍

Personally, I like the way Docker handles environment variables in their config files (YAML as well). What if we use the same approach in Phantomas YAML config files? This will be even more flexible then additional --base-url option.

Example:

url: ${HOST}/my-page

Yeah, even better!

Ah, just realized if this was supported for various configuration keys in the config file, it would also provide a way to change the report type on the fly too. Sweetness!

Let's add the env variables handling in optimist-config-file.js + move it to a separate npm module (with tests).

$ npm publish 
+ optimist-config-file@1.0.0

https://www.npmjs.com/package/optimist-config-file