patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

chore: replace fs-extra with native Node.js fs APIs

Open roli-lpci opened this issue 9 months ago • 1 comments

Summary

  • Replaces all fs-extra usage with native Node.js fs module equivalents
  • Adds inline copySync helper with file permission preservation and symlink dereferencing support
  • Removes fs-extra and @types/fs-extra from dependencies, bumps @types/node to ^14.14.0

Changes

Source files:

  • src/makePatch.ts — Added copySync helper using copyFileSync+chmodSync for permission preservation; replaced mkdirpSync → mkdirSync({recursive}), removeSync → rmSync({recursive, force})
  • src/patch/apply.ts — moveSync → renameSync, ensureDirSync → mkdirSync({recursive})
  • src/filterFiles.ts — removeSync → rmSync({force})
  • src/applyPatches.ts, src/detectPackageManager.ts, src/getAppRootPath.ts, src/getPackageResolution.ts, src/patch/read.ts — Import swap from fs-extra to fs

Test files:

  • src/patch/read.test.ts — Updated mock from fs-extra to fs
  • property-based-tests/executeTestCase.ts — Rewrote mock to spread jest.requireActual("fs") with selective overrides
  • integration-tests/runIntegrationTest.ts — Replaced fs-extra+rimraf with native fs
  • integration-tests/newIntegrationTest.ts — mkdirpSync → mkdirSync({recursive})

Dependencies:

  • package.json — Removed fs-extra, @types/fs-extra; bumped @types/node to ^14.14.0

Testing

  • 9 test suites pass (7 unit + 2 property-based), 467 tests passing
  • TypeScript compiles clean
  • All linting passes

Addresses #499

roli-lpci avatar Feb 26 '26 20:02 roli-lpci

@ds300 LGTM

james-pre avatar Apr 28 '26 19:04 james-pre