Skip to content

Commit 038194e

Browse files
committed
clean up
1 parent cedb6ab commit 038194e

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/commands/index/processRepository.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ export const processRepository = async (
7171
}): Promise<void> => {
7272
const content = await fs.readFile(filePath, 'utf-8');
7373

74-
//calculate the hash of the file
74+
/**
75+
* Calculate the checksum of the file content
76+
*/
7577
const newChecksum = await calculateChecksum([content]);
7678

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(
7984
path.join(outputRoot, filePath.substring(0, filePath.lastIndexOf('\\'))),
8085
fileName.replace(/\.[^/.]+$/, '.json'),
8186
newChecksum,
@@ -212,11 +217,20 @@ export const processRepository = async (
212217
(fileName) => !shouldIgnore(fileName),
213218
);
214219

215-
//get the checksum of all the files in the folder
220+
/**
221+
* Get the checksum of the folder
222+
*/
216223
const newChecksum = await calculateChecksum(contents);
217224

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+
);
220234
if (!reindex) {
221235
return;
222236
}
@@ -394,7 +408,9 @@ export const processRepository = async (
394408
return models;
395409
};
396410

397-
//reads all the files, and returns a checksum
411+
/**
412+
* Calculates the checksum of all the files in a folder
413+
*/
398414
async function calculateChecksum(contents: string[]): Promise<string> {
399415
const checksums: string[] = [];
400416
for (const content of contents) {
@@ -406,8 +422,13 @@ async function calculateChecksum(contents: string[]): Promise<string> {
406422
return finalChecksum;
407423
}
408424

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(
411432
contentPath: string,
412433
name: string,
413434
newChecksum: string,

src/cli/utils/traverseFileSystem.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,18 @@ export const traverseFileSystem = async (
88
params: TraverseFileSystemParams,
99
): Promise<void> => {
1010
try {
11-
// eslint-disable-next-line prettier/prettier
12-
const { inputPath, projectName, processFile, processFolder, ignore, filePrompt, folderPrompt, contentType, targetAudience, linkHosted } = params;
11+
const {
12+
inputPath,
13+
projectName,
14+
processFile,
15+
processFolder,
16+
ignore,
17+
filePrompt,
18+
folderPrompt,
19+
contentType,
20+
targetAudience,
21+
linkHosted,
22+
} = params;
1323

1424
try {
1525
await fs.access(inputPath);

0 commit comments

Comments
 (0)