Skip to content

Commit

Permalink
Remove mkdirp dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kouak committed Jun 7, 2024
1 parent 3e8224c commit d5fee7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 53 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@
},
"dependencies": {
"@date-fns/utc": "^1.2.0",
"@types/sax": "^1.2.7",
"axios": "^1.7.2",
"date-fns": "^3.6.0",
"debug": "^4.3.5",
"invariant": "^2.2.4",
"mkdirp": "^3.0.1",
"proper-lockfile": "^4.1.2",
"remeda": "^2.0.5",
"soap": "^1.0.3",
Expand Down
43 changes: 0 additions & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions src/utils/fs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import fs, { type Stats } from 'fs';
import { mkdirp } from 'mkdirp';
import { promisify } from 'util';
import * as fs from 'fs/promises';
import d from './debug';
const debug = d('dir-exists');
const stat = promisify(fs.stat);
const access = promisify(fs.access);

export async function dirExists(
path: string,
Expand All @@ -20,14 +16,14 @@ export async function dirExists(
);

try {
const stats: Stats = await stat(path);
const stats = await fs.stat(path);
if (!stats.isDirectory()) {
// Directory does not exists
return false;
}

// Check that the directory is writable and readable
await access(
await fs.access(
path,
(writable ? fs.constants.W_OK : 0) | (readable ? fs.constants.R_OK : 0),
);
Expand All @@ -42,5 +38,5 @@ export async function dirExists(

export async function createDir(path: string): Promise<void> {
debug('Creating directory %s ...', path);
await mkdirp(path);
await fs.mkdir(path, { recursive: true });
}

0 comments on commit d5fee7f

Please sign in to comment.