Skip to content

Optimize directory traversal in check-edit-links script #3586

@coderabbitai

Description

@coderabbitai

Background

Currently, the check-edit-links script reads the entire directory tree synchronously in the generatePaths function. For large documentation repositories, this could lead to performance issues.

Proposed Solution

Consider using a streaming directory reader like readdir-enhanced or implementing a generator-based solution:

async function* walkDirectory(dir) {
  const files = await fs.readdir(dir);
  for (const file of files) {
    const filePath = path.join(dir, file);
    const stats = await fs.stat(filePath);
    if (stats.isDirectory()) {
      yield* walkDirectory(filePath);
    } else {
      yield filePath;
    }
  }
}

Benefits

  • Memory efficient for large documentation repositories
  • Better performance characteristics
  • More modern async/await approach

Related PR discussion: #3557 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/typescriptSpecify what technical area given issue relates to. Its goal is to ease filtering good first issues.enhancement

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions