Skip to content

Commit

Permalink
Remove unnecessary fs-extra dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Parish committed Oct 13, 2024
1 parent 5555794 commit 485dfb0
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 68 deletions.
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
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 485dfb0

Please sign in to comment.