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 14d751e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 78 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.
4 changes: 1 addition & 3 deletions packages/get-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"license": "MIT",
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/fs-extra": "^8.1.2",
"@types/ftpd": "^0.2.35",
"@types/jest": "^29.5.1",
"@types/node": "^14.18.45",
Expand All @@ -51,8 +50,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
10 changes: 4 additions & 6 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,10 @@ 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);
// store the stat object for the cache.
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 14d751e

Please sign in to comment.