|
| 1 | +const fs = require('fs'); |
| 2 | + |
| 3 | +const files = [ |
| 4 | + 'src/components/Announcements/SocialMediaComposer.module.css', |
| 5 | + 'src/components/ApplicationAnalytics/jobAnalytics.module.css', |
| 6 | + 'src/components/BMDashboard/AddMaterial/AddMaterial.module.css', |
| 7 | + 'src/components/BMDashboard/Equipment/Update/UpdateEquipment.module.css', |
| 8 | + 'src/components/BMDashboard/Issues/issueChart.module.css', |
| 9 | + 'src/components/BMDashboard/Issues/issueCharts.module.css', |
| 10 | + 'src/components/BMDashboard/ItemList/ItemListView.module.css', |
| 11 | + 'src/components/BMDashboard/Lesson/LessonForm.module.css', |
| 12 | + 'src/components/BMDashboard/LessonList/LessonCard.module.css', |
| 13 | + 'src/components/BMDashboard/Projects/ProjectDetails/ProjectDetails.module.css', |
| 14 | + 'src/components/BMDashboard/UtilizationChart/UtilizationChart.module.css', |
| 15 | + 'src/components/BMDashboard/WeeklyProjectSummary/GroupedBarGraphInjurySeverity/InjuryCategoryBarChart.module.css', |
| 16 | + 'src/components/BMDashboard/WeeklyProjectSummary/IssueBreakdownChart.module.css', |
| 17 | + 'src/components/Collaboration/Collaboration.module.css', |
| 18 | + 'src/components/CommunityPortal/Activities/ActivityAttendance.module.css', |
| 19 | + 'src/components/CommunityPortal/Activities/activityId/ActivityComments.module.css', |
| 20 | + 'src/components/EductionPortal/EvaluationResults/EvaluationResults.module.css', |
| 21 | + 'src/components/EductionPortal/EvaluationResults/OverallPerformance.module.css', |
| 22 | + 'src/components/EductionPortal/EvaluationResults/TeacherFeedback.module.css', |
| 23 | + 'src/components/EductionPortal/StudentTasks/StudentTasks.module.css', |
| 24 | + 'src/components/EductionPortal/StudentTasks/TaskDetails.module.css', |
| 25 | + 'src/components/ExperienceDonutChart/ExperienceDonutChart.module.css', |
| 26 | + 'src/components/Header/Header.module.css', |
| 27 | + 'src/components/HGNForm/TopCommunityMembers/TopCommunityMembers.module.css', |
| 28 | + 'src/components/HGNPRDashboard/ReviewersStackedBarChart/ReviewersStackedBarChart.module.css', |
| 29 | + 'src/components/HGNSkillsDashboard/SkillsProfilePage/styles/ProfileDetails.module.css', |
| 30 | + 'src/components/LandingPage/HelpModal.module.css', |
| 31 | + 'src/components/LBDashboard/SentimentBreakdownDonutChart/SentimentBreakdownDonutChart.module.css', |
| 32 | + 'src/components/MaterialSummary/MaterialSummary.module.css', |
| 33 | + 'src/components/Projects/projects.module.css', |
| 34 | +]; |
| 35 | + |
| 36 | +function resolveKeepHead(content) { |
| 37 | + const lines = content.split('\n'); |
| 38 | + const result = []; |
| 39 | + let state = 'normal'; |
| 40 | + for (const line of lines) { |
| 41 | + if (line.startsWith('<<<<<<< ')) { |
| 42 | + state = 'head'; |
| 43 | + } else if (line === '=======' && state === 'head') { |
| 44 | + state = 'other'; |
| 45 | + } else if (line.startsWith('>>>>>>> ') && state === 'other') { |
| 46 | + state = 'normal'; |
| 47 | + } else if (state !== 'other') { |
| 48 | + result.push(line); |
| 49 | + } |
| 50 | + } |
| 51 | + return result.join('\n'); |
| 52 | +} |
| 53 | + |
| 54 | +let count = 0; |
| 55 | +for (const f of files) { |
| 56 | + if (!fs.existsSync(f)) { |
| 57 | + console.log('NOT FOUND: ' + f); |
| 58 | + continue; |
| 59 | + } |
| 60 | + const content = fs.readFileSync(f, 'utf8'); |
| 61 | + if (!content.includes('<<<<<<<')) { |
| 62 | + console.log('No conflict: ' + f); |
| 63 | + continue; |
| 64 | + } |
| 65 | + const resolved = resolveKeepHead(content); |
| 66 | + fs.writeFileSync(f, resolved, 'utf8'); |
| 67 | + console.log('Fixed: ' + f); |
| 68 | + count++; |
| 69 | +} |
| 70 | +console.log('Total: ' + count); |
0 commit comments