Skip to content

Commit

Permalink
Remove fs-extra dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
alexparish committed Oct 13, 2024
1 parent 5555794 commit 0113467
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-eagles-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'get-uri': patch
---

Removed `fs-extra` dependency and implemented its features using native Node.js functionality.
3 changes: 1 addition & 2 deletions packages/get-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"dependencies": {
"basic-ftp": "^5.0.2",
"data-uri-to-buffer": "^6.0.2",
"debug": "^4.3.4",
"fs-extra": "^11.2.0"
"debug": "^4.3.4"
},
"engines": {
"node": ">= 14"
Expand Down
7 changes: 3 additions & 4 deletions packages/get-uri/src/file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Readable } from 'stream';
import createDebug from 'debug';
import { Stats, createReadStream } from 'fs';
import { fstat, open } from 'fs-extra';
import { Stats, createReadStream, promises as fsPromises } from 'fs';
import { GetUriProtocol } from './';
import NotFoundError from './notfound';
import NotModifiedError from './notmodified';
Expand Down Expand Up @@ -42,11 +41,11 @@ export const file: GetUriProtocol<FileOptions> = async (

// `open()` first to get a file descriptor and ensure that the file
// exists.
const fd = await open(filepath, flags, mode);
const fd = await fsPromises.open(filepath, flags, mode);

// Now `fstat()` to check the `mtime` and store the stat object for
// the cache.
const stat = await fstat(fd);
const stat = await fd.stat();

// if a `cache` was provided, check if the file has not been modified
if (cache && cache.stat && stat && isNotModified(cache.stat, stat)) {
Expand Down
Loading

0 comments on commit 0113467

Please sign in to comment.