Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

Commit bab1954

Browse files
committed
bring back pre-commit
flatten: stringify array properties instead of failing with error
1 parent ade315a commit bab1954

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
#pnpm pre-commit
4+
pnpm pre-commit

core/jlib/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ export function flatten(obj: any, { separator = "_", skipArrays = false } = {},
237237
if (value == null) {
238238
res[key] = value;
239239
} else {
240-
if (typeof value === "object") {
240+
if (Array.isArray(value)) {
241+
if (!skipArrays) {
242+
res[key] = JSON.stringify(value);
243+
}
244+
} else if (typeof value === "object") {
241245
Object.entries(flatten(value, { separator, skipArrays }, [...path, key])).forEach(
242246
([subKey, subValue]) => (res[key + separator + subKey] = subValue)
243247
);

0 commit comments

Comments
 (0)