Skip to content

Commit 5914f35

Browse files
committed
fix: use fs utils to remove directory
1 parent b02caf9 commit 5914f35

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

v-next/hardhat/test/internal/builtin-plugins/console/task-action.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import type { HardhatRuntimeEnvironment } from "@ignored/hardhat-vnext-core/type
22
import type repl from "node:repl";
33

44
import assert from "node:assert/strict";
5-
import fs from "node:fs";
5+
import fsPromises from "node:fs/promises";
66
import os from "node:os";
77
import path from "node:path";
88
import { PassThrough } from "node:stream";
99
import { afterEach, before, beforeEach, describe, it } from "node:test";
1010

1111
import { ensureError } from "@ignored/hardhat-vnext-utils/error";
12+
import { exists, remove } from "@ignored/hardhat-vnext-utils/fs";
1213

1314
import { createHardhatRuntimeEnvironment } from "../../../../src/hre.js";
1415
import consoleAction from "../../../../src/internal/builtin-plugins/console/task-action.js";
@@ -137,20 +138,20 @@ describe("console/task-action", function () {
137138
let cacheDir: string;
138139
let history: string;
139140

140-
beforeEach(function () {
141-
cacheDir = fs.mkdtempSync(
141+
beforeEach(async function () {
142+
cacheDir = await fsPromises.mkdtemp(
142143
path.resolve(os.tmpdir(), "console-action-test-"),
143144
);
144145
history = path.resolve(cacheDir, "console-history.txt");
145146
});
146147

147-
afterEach(function () {
148-
fs.rmSync(cacheDir, { recursive: true, force: true });
148+
afterEach(async function () {
149+
await remove(cacheDir);
149150
});
150151

151152
it("should create a history file", async function () {
152153
assert.ok(
153-
!fs.existsSync(history),
154+
!(await exists(history)),
154155
"History file exists before running the console",
155156
);
156157
const replServer = await consoleAction(
@@ -164,7 +165,7 @@ describe("console/task-action", function () {
164165
);
165166
assert.equal(replServer.lastError, undefined);
166167
assert.ok(
167-
fs.existsSync(history),
168+
await exists(history),
168169
"History file does not exist after running the console",
169170
);
170171
});

0 commit comments

Comments
 (0)