-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.js
32 lines (28 loc) · 866 Bytes
/
scripts.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
const fs = require("fs");
const path = require("path");
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
});
const dataset = require("./dataset.json");
const {
getLocation,
getGender,
getYOE,
getEducation,
getSalary,
getSatisfaction,
} = require("./helpers");
const root = process.cwd();
const chartsPath = "/src/data/charts";
const finalPath = path.join(root, chartsPath);
const writeJsonToFile = (json, filename) => {
fs.writeFile(path.join(finalPath, `${filename}.json`), json, (err) => {
if (err) console.log(err);
});
};
writeJsonToFile(getLocation(dataset), "location");
writeJsonToFile(getGender(dataset), "gender");
writeJsonToFile(getYOE(dataset), "yoe");
writeJsonToFile(getEducation(dataset), "education");
writeJsonToFile(getSalary(dataset), "salary");
writeJsonToFile(getSatisfaction(dataset), "satisfaction");