Skip to content

Commit 80cf025

Browse files
committed
[INTERNAL] Use native fs.mkdir instead of make-dir
The recursive option is available since Node v10.12, which makes the use of thirdparty packages obsolete for most use cases.
1 parent ea207c6 commit 80cf025

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

lib/adapters/FileSystem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {promisify} from "node:util";
55
import fs from "graceful-fs";
66
const copyFile = promisify(fs.copyFile);
77
const chmod = promisify(fs.chmod);
8+
const mkdir = promisify(fs.mkdir);
89
import {globby} from "globby";
9-
import makeDir from "make-dir";
1010
import {PassThrough} from "node:stream";
1111
import AbstractAdapter from "./AbstractAdapter.js";
1212

@@ -220,7 +220,7 @@ class FileSystem extends AbstractAdapter {
220220
const fsPath = path.join(this._fsBasePath, relPath);
221221
const dirPath = path.dirname(fsPath);
222222

223-
await makeDir(dirPath, {fs});
223+
await mkdir(dirPath, {recursive: true});
224224

225225
const resourceSource = resource.getSource();
226226
if (!resourceSource.modified && resourceSource.adapter === "FileSystem" && resourceSource.fsPath) {

package-lock.json

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
"escape-string-regexp": "^5.0.0",
127127
"globby": "^13.1.2",
128128
"graceful-fs": "^4.2.10",
129-
"make-dir": "^3.1.0",
130129
"micromatch": "^4.0.5",
131130
"minimatch": "^5.1.0",
132131
"pretty-hrtime": "^1.0.3",

test/lib/adapters/FileSystem_write.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import path from "node:path";
22
import {promisify} from "node:util";
3-
import fs from "node:fs";
3+
import {access as fsAccess, constants as fsConstants, mkdir} from "node:fs/promises";
44
import {fileURLToPath} from "node:url";
5-
const fsAccess = promisify(fs.access);
6-
import makeDir from "make-dir";
75
import test from "ava";
86
import rimraf from "rimraf";
97
const rimrafp = promisify(rimraf);
@@ -20,7 +18,7 @@ test.beforeEach(async (t) => {
2018

2119
// Create a tmp directory for every test
2220
t.context.tmpDirPath = fileURLToPath(new URL("../../tmp/adapters/FileSystemWrite/" + tmpDirName, import.meta.url));
23-
await makeDir(t.context.tmpDirPath);
21+
await mkdir(t.context.tmpDirPath, {recursive: true});
2422

2523
t.context.readerWriters = {
2624
source: createAdapter({
@@ -63,8 +61,8 @@ test("Write resource in readOnly mode", async (t) => {
6361
// Write resource content to another readerWriter
6462
await readerWriters.dest.write(resource, {readOnly: true});
6563

66-
await t.notThrowsAsync(fsAccess(destFsPath, fs.constants.R_OK), "File can be read");
67-
await t.throwsAsync(fsAccess(destFsPath, fs.constants.W_OK),
64+
await t.notThrowsAsync(fsAccess(destFsPath, fsConstants.R_OK), "File can be read");
65+
await t.throwsAsync(fsAccess(destFsPath, fsConstants.W_OK),
6866
{message: /EACCES: permission denied|EPERM: operation not permitted/},
6967
"File can not be written");
7068

0 commit comments

Comments
 (0)