forked from uc-cdis/data-portal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sanity-check.js
39 lines (35 loc) · 1.06 KB
/
sanity-check.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
const dict = require('./data/dictionary.json');
const params = require('./src/params.js');
function makeSureHomepageChartWorks() {
/**
* this transfer '_xxx_count' to 'xxx'
* @param {string} countName
*/
function parseNodeType(countName) {
return countName.substring(1, countName.length - '_count'.length);
}
const boardCountNodes = params.config.graphql.boardCounts.map((e) =>
parseNodeType(e.graphql)
);
const chartCountNodes = params.config.graphql.chartCounts.map((e) =>
parseNodeType(e.graphql)
);
/**
* Check if all nodes exist in dictionary
* @param {string[]} nodeList
*/
function checkNodesExistInDict(nodeList) {
for (let i = 0; i < nodeList.length; i += 1) {
const nodeID = nodeList[i];
if (typeof dict[nodeID] === 'undefined') {
// eslint-disable-next-line no-console
console.error(`ERR: "${nodeID}" does not exist`);
process.exit(1);
}
}
}
checkNodesExistInDict(boardCountNodes);
checkNodesExistInDict(chartCountNodes);
}
makeSureHomepageChartWorks();
process.exit(0);