@percy/config 1.10.3 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,21 +13,26 @@ export function camelcase(str) {
13
13
  export function kebabcase(str) {
14
14
  if (typeof str !== 'string') return str;
15
15
  return Array.from(CAMELCASE_MAP).reduce((str, [word, camel]) => str.replace(camel, `-${word}`), str).match(WORD_REG).join('-').toLowerCase();
16
+ } // Coverts kebab-case and camelCased strings to snake_case.
17
+
18
+ export function snakecase(str) {
19
+ if (typeof str !== 'string') return str;
20
+ return Array.from(CAMELCASE_MAP).reduce((str, [word, camel]) => str.replace(camel, `_${word}`), str).match(WORD_REG).join('_').toLowerCase();
16
21
  } // Removes undefined empty values and renames kebab-case properties to camelCase. Optionally
17
22
  // allows deep merging with options.overrides, converting keys to kebab-case with options.kebab,
18
23
  // and normalizing against a schema with options.schema.
19
24
 
20
25
  export function normalize(object, options) {
21
- var _options, _options2;
26
+ var _options, _options2, _options3;
22
27
 
23
28
  if (typeof options === 'string') options = {
24
29
  schema: options
25
30
  };
26
- let keycase = (_options = options) !== null && _options !== void 0 && _options.kebab ? kebabcase : camelcase;
27
- return merge([object, (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.overrides], (path, value) => {
28
- var _options3, _schemas$shift;
31
+ let keycase = (_options = options) !== null && _options !== void 0 && _options.kebab ? kebabcase : (_options2 = options) !== null && _options2 !== void 0 && _options2.snake ? snakecase : camelcase;
32
+ return merge([object, (_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.overrides], (path, value) => {
33
+ var _options4, _schemas$shift;
29
34
 
30
- let schemas = getSchema((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.schema, path.map(camelcase));
35
+ let schemas = getSchema((_options4 = options) === null || _options4 === void 0 ? void 0 : _options4.schema, path.map(camelcase));
31
36
  let skip = ((_schemas$shift = schemas.shift()) === null || _schemas$shift === void 0 ? void 0 : _schemas$shift.normalize) === false;
32
37
  let mapped = []; // skip normalizing paths of class instances
33
38
 
@@ -36,9 +41,9 @@ export function normalize(object, options) {
36
41
  }
37
42
 
38
43
  for (let [i, k] of path.entries()) {
39
- var _options4, _options4$skip, _schemas$i;
44
+ var _options5, _options5$skip, _schemas$i;
40
45
 
41
- skip || (skip = (_options4 = options) === null || _options4 === void 0 ? void 0 : (_options4$skip = _options4.skip) === null || _options4$skip === void 0 ? void 0 : _options4$skip.call(_options4, mapped.concat(k)));
46
+ skip || (skip = (_options5 = options) === null || _options5 === void 0 ? void 0 : (_options5$skip = _options5.skip) === null || _options5$skip === void 0 ? void 0 : _options5$skip.call(_options5, mapped.concat(k)));
42
47
  mapped.push(skip ? k : keycase(k));
43
48
  skip || (skip = ((_schemas$i = schemas[i]) === null || _schemas$i === void 0 ? void 0 : _schemas$i.normalize) === false);
44
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/config",
3
- "version": "1.10.3",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "test:types": "tsd"
35
35
  },
36
36
  "dependencies": {
37
- "@percy/logger": "1.10.3",
37
+ "@percy/logger": "1.11.0",
38
38
  "ajv": "^8.6.2",
39
39
  "cosmiconfig": "^7.0.0",
40
40
  "yaml": "^2.0.0"
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "json-schema-typed": "^7.0.3"
44
44
  },
45
- "gitHead": "a9858d20a9b9708da0464c0617b32b2ee1c97433"
45
+ "gitHead": "0a5043cd677266390889063924f342af9b347055"
46
46
  }