@percy/config
Advanced tools
Comparing version 1.0.0-beta.33 to 1.0.0-beta.34
@@ -94,3 +94,5 @@ "use strict"; | ||
config = (0, _normalize.default)(config, overrides); | ||
config = (0, _normalize.default)(config, { | ||
overrides | ||
}); | ||
let validation = config && (0, _validate.default)(config); | ||
@@ -97,0 +99,0 @@ |
@@ -16,11 +16,15 @@ "use strict"; | ||
const CAMELIZE_MAP = { | ||
css: 'CSS', | ||
javascript: 'JavaScript' | ||
}; // Converts kebab-cased and snake_cased strings to camelCase. | ||
const CAMELCASE_MAP = new Map([['css', 'CSS'], ['javascript', 'JavaScript']]); // Converts kebab-cased and snake_cased strings to camelCase. | ||
const KEBAB_SNAKE_REG = /(-|_)([^\1]+)/g; | ||
const KEBAB_SNAKE_REG = /[-_]([^-_]+)/g; | ||
function camelize(str) { | ||
return str.replace(KEBAB_SNAKE_REG, (match, sep, word) => CAMELIZE_MAP[word] || word[0].toUpperCase() + word.slice(1)); | ||
function camelcase(str) { | ||
return str.replace(KEBAB_SNAKE_REG, (match, word) => CAMELCASE_MAP.get(word) || word[0].toUpperCase() + word.slice(1)); | ||
} // Coverts camelCased and snake_cased strings to kebab-case. | ||
const CAMEL_SNAKE_REG = /([a-z])([A-Z]+)|_([^_]+)/g; | ||
function kebabcase(str) { | ||
return Array.from(CAMELCASE_MAP).reduce((str, [word, camel]) => str.replace(camel, `-${word}`), str).replace(CAMEL_SNAKE_REG, (match, p, n, w) => `${p || ''}-${(n || w).toLowerCase()}`); | ||
} // Merges source values into the target object unless empty. When `options.replaceArrays` is truthy, | ||
@@ -34,14 +38,17 @@ // target arrays are replaced by their source arrays rather than concatenated together. | ||
if (typeof source !== 'object') return source != null ? source : target; | ||
let convertcase = options !== null && options !== void 0 && options.kebab ? kebabcase : camelcase; | ||
return entries(source).reduce((result, [key, value]) => { | ||
value = merge(result === null || result === void 0 ? void 0 : result[key], value, options); | ||
return value == null ? result : isSourceArray ? (result || []).concat(value) : assign(result || {}, { | ||
[camelize(key)]: value | ||
[convertcase(key)]: value | ||
}); | ||
}, target); | ||
} // Recursively reduces config objects and arrays to remove undefined and empty values and rename | ||
// kebab-case properties to camelCase. Optionally allows deep merging of override values | ||
// kebab-case properties to camelCase. Optionally allows deep merging of a second overrides | ||
// argument, and converting keys to kebab-case with a third options.kebab argument. | ||
function normalize(object, overrides) { | ||
return merge(merge(undefined, object), overrides); | ||
function normalize(object, options) { | ||
object = merge(undefined, object, options); | ||
return options !== null && options !== void 0 && options.overrides ? merge(object, options.overrides, options) : object; | ||
} |
{ | ||
"name": "@percy/config", | ||
"version": "1.0.0-beta.33", | ||
"version": "1.0.0-beta.34", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@percy/logger": "^1.0.0-beta.33", | ||
"@percy/logger": "^1.0.0-beta.34", | ||
"ajv": "^7.0.3", | ||
@@ -37,3 +37,3 @@ "cosmiconfig": "^7.0.0", | ||
}, | ||
"gitHead": "8495d980d284599584f748b4ef33bd39acdb8ba0" | ||
"gitHead": "33915b5865c49bf8ef38c6f7a9eaf9e164869518" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19145
380
Updated@percy/logger@^1.0.0-beta.34