Skip to content

Commit 3dda399

Browse files
Fix: Output the _type for items that are missing/orphaned (issue/3720) (#3721)
1 parent 3cea93f commit 3dda399

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

grunt/helpers/data/Language.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,25 @@ class Language {
199199
emptyIds[o._id] = true; // Course has no children
200200
}
201201
if (!isCourseType && (!o._parentId || !idIndex[o._parentId])) {
202-
orphanedIds[o._id] = true; // Item has no defined parent id or the parent id doesn't exist
202+
orphanedIds[o._id] = o._type; // Item has no defined parent id or the parent id doesn't exist
203203
}
204204
if (!isCourseType && o._parentId && !idIndex[o._parentId]) {
205-
missingIds[o._parentId] = true; // Referenced parent item does not exist
205+
missingIds[o._parentId] = o._type; // Referenced parent item does not exist
206206
}
207207
});
208-
orphanedIds = Object.keys(orphanedIds);
208+
const orphanedIdsArray = Object.keys(orphanedIds);
209+
const missingIdsArray = Object.keys(missingIds);
209210
emptyIds = Object.keys(emptyIds);
210211
duplicateIds = Object.keys(duplicateIds);
211-
missingIds = Object.keys(missingIds);
212212
// Output for each type of error
213-
const hasErrored = orphanedIds.length || emptyIds.length || duplicateIds.length || missingIds.length;
214-
if (orphanedIds.length) {
215-
this.log(chalk.yellow(`Orphaned _ids: ${orphanedIds}`));
213+
const hasErrored = orphanedIdsArray.length || emptyIds.length || duplicateIds.length || missingIdsArray.length;
214+
if (orphanedIdsArray.length) {
215+
const orphanedIdString = orphanedIdsArray.map((id) => `${id} (${orphanedIds[id]})`);
216+
this.log(chalk.yellow(`Orphaned _ids: ${orphanedIdString.join(', ')}`));
216217
}
217-
if (missingIds.length) {
218-
this.log(chalk.yellow(`Missing _ids: ${missingIds}`));
218+
if (missingIdsArray.length) {
219+
const missingIdString = missingIdsArray.map((id) => `${id} (${missingIds[id]})`);
220+
this.log(chalk.yellow(`Missing _ids: ${missingIdString.join(', ')}`));
219221
}
220222
if (emptyIds.length) {
221223
this.log(chalk.yellow(`Empty _ids: ${emptyIds}`));

0 commit comments

Comments
 (0)