Write theme JSON files from buildThemes script

Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
This commit is contained in:
Nathan Sobo 2022-04-01 09:45:11 -06:00 committed by Keith Simmons
parent 70a783c8d1
commit d2a070c345
9 changed files with 771 additions and 445 deletions

View file

@ -0,0 +1,21 @@
import { snakeCase } from "case-anything";
export default function decamelizeTree(object: { [key: string]: any }) {
const snakeObject: { [key: string]: any } = {};
for (const key in object) {
snakeObject[snakeCase(key)] = decamelizeValue(object[key]);
}
return snakeObject;
}
function decamelizeValue(value: any): any {
if (typeof value === "object") {
if (Array.isArray(value)) {
return value.map(decamelizeValue);
} else {
return decamelizeTree(value);
}
} else {
return value;
}
}