Skip to content

Conversation

@joemanley201
Copy link
Contributor

@joemanley201 joemanley201 commented Feb 20, 2025

Description

Fix the reported issue where the extension breaks if it is a directory
#1092 (comment)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added unit tests

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Introduces safeReadFile to handle file reading errors gracefully in custom-instructions.ts, with tests added in custom-instructions.test.ts.

  • Behavior:
    • Introduces safeReadFile in custom-instructions.ts to handle ENOENT and EISDIR errors gracefully, returning an empty string instead of throwing.
    • Updates loadRuleFiles and addCustomInstructions in custom-instructions.ts to use safeReadFile for reading files.
  • Tests:
    • Adds unit tests in custom-instructions.test.ts to verify safeReadFile behavior for ENOENT, EISDIR, and unexpected errors.
    • Tests loadRuleFiles and addCustomInstructions for correct handling of directories and missing files.

This description was created by Ellipsis for 053671e. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2025

⚠️ No Changeset found

Latest commit: 007bf18

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same diff is being generated if I run npm run install:all on main. Looks like we missed it here #1051 maybe?

@joemanley201 joemanley201 marked this pull request as ready for review February 20, 2025 20:39
if (content.trim()) {
modeRuleContent = content.trim()
}
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, consider using a shared helper for error checks here as well to improve maintainability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, thanks!

Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@joemanley201 joemanley201 merged commit 6ae11dd into main Feb 20, 2025
6 checks passed
@joemanley201 joemanley201 deleted the jm/handle-directory branch February 20, 2025 20:56
joemanley201 added a commit that referenced this pull request Feb 20, 2025
@joemanley201 joemanley201 mentioned this pull request Feb 20, 2025
8 tasks
joemanley201 added a commit that referenced this pull request Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants