@@ -20,16 +20,16 @@ const consoleAction: NewTaskActionFunction<ConsoleActionArguments> = async (
20
20
{ commands, history, options } ,
21
21
hre ,
22
22
) => {
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
+
33
33
// Start a new REPL server with the default options
34
34
const replServer = repl . start ( options ) ;
35
35
@@ -43,11 +43,14 @@ const consoleAction: NewTaskActionFunction<ConsoleActionArguments> = async (
43
43
44
44
// Set up the REPL history file if the historyPath has been set
45
45
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
+ } ) ;
51
54
} ) ;
52
55
}
53
56
0 commit comments