-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-json.js
More file actions
30 lines (25 loc) · 1.03 KB
/
update-json.js
File metadata and controls
30 lines (25 loc) · 1.03 KB
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
import fs from 'fs';
const path = './src/data/roadmapData.json';
const data = JSON.parse(fs.readFileSync(path, 'utf8'));
// Add imageUrl field to all documentation objects
data.weeks.forEach(week => {
// Add to daily tasks
week.dailyTasks.forEach(task => {
if (task.documentation && !task.documentation.imageUrl) {
task.documentation.imageUrl = '';
}
});
// Add to project documentation
if (week.project && week.project.documentation && !week.project.documentation.imageUrl) {
week.project.documentation.imageUrl = '';
}
});
// Add to global documentation
if (data.progressTracking && data.progressTracking.documentation && !data.progressTracking.documentation.imageUrl) {
data.progressTracking.documentation.imageUrl = '';
}
if (data.finalProject && data.finalProject.documentation && !data.finalProject.documentation.imageUrl) {
data.finalProject.documentation.imageUrl = '';
}
fs.writeFileSync(path, JSON.stringify(data, null, 2));
console.log('Successfully added imageUrl field to all documentation objects');