-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathorder.js
More file actions
29 lines (23 loc) · 923 Bytes
/
order.js
File metadata and controls
29 lines (23 loc) · 923 Bytes
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
import fs from 'fs';
import path from 'path';
const orderFilePath = path.join('src', 'routes', 'team', 'order.json');
let orderData;
try {
orderData = JSON.parse(fs.readFileSync(orderFilePath, 'utf-8'));
} catch (error) {
console.error(`Error reading order.json: ${error.message}`);
orderData = {}; // Handle as empty object or suitable default
}
const mdFiles = fs.readdirSync(path.join('src', 'routes', 'team')).filter(file => file.endsWith('.md'));
const mdFileNames = mdFiles.map(file => file.replace('.md', ''));
const orderEntries = Object.keys(orderData);
orderEntries.forEach(entry => {
if (!mdFileNames.includes(entry)) {
console.error(`Error: Entry "${entry}" in order.json has no corresponding Markdown file.`);
}
});
mdFileNames.forEach(fileName => {
if (!orderEntries.includes(fileName)) {
console.error(`Error: Markdown file "${fileName}.md" is not listed in order.json.`);
}
});