@@ -71,11 +71,16 @@ export const processRepository = async (
71
71
} ) : Promise < void > => {
72
72
const content = await fs . readFile ( filePath , 'utf-8' ) ;
73
73
74
- //calculate the hash of the file
74
+ /**
75
+ * Calculate the checksum of the file content
76
+ */
75
77
const newChecksum = await calculateChecksum ( [ content ] ) ;
76
78
77
- //if an existing .json file exists, it will check the checksums and decide if a reindex is needed
78
- const reindex = await reindexCheck (
79
+ /**
80
+ * if an existing .json file exists,
81
+ * it will check the checksums and decide if a reindex is needed
82
+ */
83
+ const reindex = await shouldReindex (
79
84
path . join ( outputRoot , filePath . substring ( 0 , filePath . lastIndexOf ( '\\' ) ) ) ,
80
85
fileName . replace ( / \. [ ^ / . ] + $ / , '.json' ) ,
81
86
newChecksum ,
@@ -212,11 +217,20 @@ export const processRepository = async (
212
217
( fileName ) => ! shouldIgnore ( fileName ) ,
213
218
) ;
214
219
215
- //get the checksum of all the files in the folder
220
+ /**
221
+ * Get the checksum of the folder
222
+ */
216
223
const newChecksum = await calculateChecksum ( contents ) ;
217
224
218
- //if an existing summary.json file exists, it will check the checksums and decide if a reindex is needed
219
- const reindex = await reindexCheck ( folderPath , 'summary.json' , newChecksum ) ;
225
+ /**
226
+ * If an existing summary.json file exists,
227
+ * it will check the checksums and decide if a reindex is needed
228
+ */
229
+ const reindex = await shouldReindex (
230
+ folderPath ,
231
+ 'summary.json' ,
232
+ newChecksum ,
233
+ ) ;
220
234
if ( ! reindex ) {
221
235
return ;
222
236
}
@@ -394,7 +408,9 @@ export const processRepository = async (
394
408
return models ;
395
409
} ;
396
410
397
- //reads all the files, and returns a checksum
411
+ /**
412
+ * Calculates the checksum of all the files in a folder
413
+ */
398
414
async function calculateChecksum ( contents : string [ ] ) : Promise < string > {
399
415
const checksums : string [ ] = [ ] ;
400
416
for ( const content of contents ) {
@@ -406,8 +422,13 @@ async function calculateChecksum(contents: string[]): Promise<string> {
406
422
return finalChecksum ;
407
423
}
408
424
409
- //checks if a summary.json file exists, and if it does, compares the checksums to see if it needs to be re-indexed or not.
410
- async function reindexCheck (
425
+ /**
426
+ * Checks if a summary.json file exists.
427
+ * If it does, compares the checksums to see if it
428
+ * needs to be re-indexed or not.
429
+ */
430
+
431
+ async function shouldReindex (
411
432
contentPath : string ,
412
433
name : string ,
413
434
newChecksum : string ,
0 commit comments