Skip to content

Commit a0ecee1

Browse files
committed
fix: await history setup
1 parent f73612f commit a0ecee1

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

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

+18-15
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ const consoleAction: NewTaskActionFunction<ConsoleActionArguments> = async (
2020
{ commands, history, options },
2121
hre,
2222
) => {
23-
// Resolve the history path if it is not empty
24-
let historyPath: string | undefined;
25-
if (history !== "") {
26-
const globalCacheDir = await getCacheDir();
27-
historyPath = path.isAbsolute(history)
28-
? history
29-
: path.resolve(globalCacheDir, history);
30-
}
31-
32-
return new Promise<REPLServer>((resolve) => {
23+
return new Promise<REPLServer>(async (resolve) => {
24+
// Resolve the history path if it is not empty
25+
let historyPath: string | undefined;
26+
if (history !== "") {
27+
const globalCacheDir = await getCacheDir();
28+
historyPath = path.isAbsolute(history)
29+
? history
30+
: path.resolve(globalCacheDir, history);
31+
}
32+
3333
// Start a new REPL server with the default options
3434
const replServer = repl.start(options);
3535

@@ -43,11 +43,14 @@ const consoleAction: NewTaskActionFunction<ConsoleActionArguments> = async (
4343

4444
// Set up the REPL history file if the historyPath has been set
4545
if (historyPath !== undefined) {
46-
replServer.setupHistory(historyPath, (err: Error | null) => {
47-
// Fail silently if the history file cannot be set up
48-
if (err !== null) {
49-
log(`Failed to setup REPL history: ${err.message}`);
50-
}
46+
await new Promise<void>((resolveSetupHistory) => {
47+
replServer.setupHistory(historyPath, (err: Error | null) => {
48+
// Fail silently if the history file cannot be set up
49+
if (err !== null) {
50+
log(`Failed to setup REPL history: ${err.message}`);
51+
}
52+
resolveSetupHistory();
53+
});
5154
});
5255
}
5356

0 commit comments

Comments
 (0)