-
Notifications
You must be signed in to change notification settings - Fork 9
/
check-db.js
31 lines (27 loc) · 799 Bytes
/
check-db.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
require("dotenv").config();
const fs = require("fs");
const { Elm } = require("./check-db-app");
const lib = require("./lib");
const { ECOBALYSE_DATA_DIR } = process.env;
let dataFiles;
try {
dataFiles = lib.getDataFiles(ECOBALYSE_DATA_DIR);
} catch (err) {
console.error(`🚨 ERROR: ${err.message}`);
process.exit(1);
}
const elmApp = Elm.CheckDb.init({
flags: {
foodProcesses: fs.readFileSync(dataFiles.foodDetailed, "utf-8"),
objectProcesses: fs.readFileSync(dataFiles.objectDetailed, "utf-8"),
textileProcesses: fs.readFileSync(dataFiles.textileDetailed, "utf-8"),
},
});
elmApp.ports.logAndExit.subscribe(({ message, status }) => {
if (status > 0) {
console.error(`🚨 ERROR: ${message}`);
} else {
console.info(message);
}
process.exit(status);
});