Handles loading and adding options to Percy configuration files. Uses cosmiconfig to load configuration files and JSON schema with AJV to validate those configuration files.
The .load()
method will load and validate a configuation file, optionally merging it with any
provided overrides
. If no path
is provided, will search for the first supported config found
from the current directory up to the home directoy. Configuration files are cached and reused unless
reload
is true
.
import PercyConfig from '@percy/config'
// loading is done synchronously
const config = PercyConfig.load(options)
path
— Config file path or directory containing a config fileoverrides
— Config option overridesreload
— Do not use cached config (defaultfalse
)bail
— Return undefined when failing validation (defaultfalse
)print
— Print info and error logs (defaultfalse
)
"percy"
entry inpackage.json
.percyrc
YAML or JSON file.percy.json
JSON file.percy.yaml
or.percy.yml
YAML file.percy.js
orpercy.config.js
file that exports an object
The .addSchema()
function will add a sub-schema to the Percy configuration file which will be
parsed and validated when PercyConfig.load()
is called. See JSON
schema for possible schema options.
import PercyConfig from '@percy/config'
PercyConfig.addSchema({
propertyName: JSONSchema
})