Skip to content

fix: drop fs-extra for native fs/promises#950

Merged
ferhatelmas merged 1 commit intomasterfrom
ferhat/fs-extra
Mar 30, 2026
Merged

fix: drop fs-extra for native fs/promises#950
ferhatelmas merged 1 commit intomasterfrom
ferhat/fs-extra

Conversation

@ferhatelmas
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Refactor

What is the current behavior?

fs-extra is used for promise based fs API.

What is the new behavior?

Use native fs/promises and drop fs-extra.

Additional context

Docs

@ferhatelmas ferhatelmas requested a review from a team as a code owner March 30, 2026 13:08
Copilot AI review requested due to automatic review settings March 30, 2026 13:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors filesystem usage to remove the fs-extra dependency and rely on Node’s native fs/promises, adding small internal helper wrappers to cover common fs-extra conveniences.

Changes:

  • Removed fs-extra (and its types) from dependencies.
  • Added @internal/fs helpers (ensureDir, ensureFile, pathExists, removePath) and migrated storage code to use them.
  • Updated file-backend tests and TUS file-store integration to use native fs/promises plus the new helpers.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/test/file-backend.test.ts Replaces fs-extra usage with node:fs/promises and removePath for cleanup.
src/storage/protocols/tus/file-store.ts Uses ensureFile helper instead of fs-extra.ensureFile.
src/storage/backend/file.ts Migrates most fs-extra operations to native fsp + @internal/fs wrappers.
src/internal/fs.ts Introduces internal replacements for a subset of fs-extra functionality.
package.json Drops fs-extra and @types/fs-extra dependencies.
package-lock.json Removes fs-extra and @types/fs-extra entries.
Comments suppressed due to low confidence (1)

src/storage/backend/file.ts:233

  • deleteObject now uses removePath(), which calls fs.rm(..., { force: true }) and therefore will not throw ENOENT for missing paths. The special-case ENOENT handling in this catch block is now effectively dead code; consider simplifying the error handling (or switching to a non-force removal if you want missing files to still surface here).
  async deleteObject(bucket: string, key: string, version: string | undefined): Promise<void> {
    try {
      const file = this.resolveSecurePath(withOptionalVersion(`${bucket}/${key}`, version))
      await removePath(file)

      // Clean up empty parent directories
      await this.cleanupEmptyDirectories(path.dirname(file))
    } catch (e) {
      if (e instanceof Error && 'code' in e) {
        if ((e as any).code === 'ENOENT') {
          return
        }
        throw e
      }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 30, 2026

Pull Request Test Coverage Report for Build 23749420723

Details

  • 44 of 53 (83.02%) changed or added relevant lines in 3 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 80.388%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/storage/protocols/tus/file-store.ts 1 2 50.0%
src/internal/fs.ts 25 27 92.59%
src/storage/backend/file.ts 18 24 75.0%
Files with Coverage Reduction New Missed Lines %
src/storage/protocols/tus/s3-locker.ts 4 88.57%
Totals Coverage Status
Change from base Build 23744481550: 0.02%
Covered Lines: 29726
Relevant Lines: 36800

💛 - Coveralls

@ferhatelmas ferhatelmas merged commit 9e8c435 into master Mar 30, 2026
3 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/fs-extra branch March 30, 2026 14:24
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.

4 participants