@newrelic/gatsby-theme-newrelic
Version:
[](https://opensource.newrelic.com/oss-category/#community-project)
21 lines (16 loc) • 494 B
JavaScript
const { merge, omit } = require('lodash');
const getResolvedEnv = require('./config/resolvedEnv');
const buildConfigGetter =
(configKey, { defaults = {}, envOptions = false } = {}) =>
(themeOptions) => {
const config = themeOptions[configKey];
if (!config) {
return null;
}
return merge(
defaults,
omit(config, ['env']),
envOptions && config.env ? config.env[getResolvedEnv(themeOptions)] : {}
);
};
module.exports = { buildConfigGetter };