-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
23 lines (17 loc) · 927 Bytes
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { readdirSync, mkdirSync, writeFileSync } = require('fs');
// Get the json files from the @yummly/pasta-dictionary package and move them to the _data directory
const projectDirectories = readdirSync('./node_modules/@yummly/pasta-dictionary/dist');
projectDirectories.forEach((project) => {
mkdirSync(`./docs/_data/${project}`, { recursive: true });
const tokenFiles = readdirSync(`./node_modules/@yummly/pasta-dictionary/dist/${project}/knowledge-base`);
tokenFiles.forEach((tokenFile) => {
const file = require(`./node_modules/@yummly/pasta-dictionary/dist/${project}/knowledge-base/${tokenFile}`);
const tokens = file._tokens;
// Loop through each token object and write it to a file
Object.keys(tokens).forEach((token) => {
const tokenObject = tokens[token];
writeFileSync
(`./docs/_data/${project}/${token}.json`, JSON.stringify(tokenObject, null, 2));
});
});
});