-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.js
41 lines (39 loc) · 1023 Bytes
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module.exports = {
source: ["tokens/converted-tokens-w3c.json"],
platforms: {
js: {
transformGroup: "js",
buildPath: "converted/js/",
files: [
{
destination: "tokens.json",
format: "json",
},
],
},
},
parsers: [
{
pattern: "tokens/converted-tokens-w3c.json",
parse: ({ contents }) => {
const dsContent = JSON.parse(contents).ds;
// Whenever we reach a $value and $type on the same level, take only the $value and assigned it to the key.
// This is to make the structure more flat
const flatten = (obj) => {
const result = {};
Object.keys(obj).forEach((key) => {
if (obj[key].$value && obj[key].$type) {
result[key] = obj[key].$value;
} else {
result[key] = flatten(obj[key]);
}
});
return result;
};
return {
...flatten(dsContent),
};
},
},
],
};