(onReadyCallback)
| 78 | } |
| 79 | |
| 80 | initialize(onReadyCallback) { |
| 81 | // Empty string disables persistent history |
| 82 | if (this[kHistoryPath] === '') { |
| 83 | // Save a reference to the context's original _historyPrev |
| 84 | this.historyPrev = this[kContext]._historyPrev; |
| 85 | this[kContext]._historyPrev = this[kReplHistoryMessage].bind(this); |
| 86 | return onReadyCallback(null, this[kContext]); |
| 87 | } |
| 88 | |
| 89 | const resolvedPath = this[kResolveHistoryPath](); |
| 90 | if (!resolvedPath) { |
| 91 | ReplHistory[kWriteToOutput]( |
| 92 | this[kContext], |
| 93 | '\nError: Could not get the home directory.\n' + |
| 94 | 'REPL session history will not be persisted.\n', |
| 95 | ); |
| 96 | |
| 97 | // Save a reference to the context's original _historyPrev |
| 98 | this.historyPrev = this[kContext]._historyPrev; |
| 99 | this[kContext]._historyPrev = this[kReplHistoryMessage].bind(this); |
| 100 | return onReadyCallback(null, this[kContext]); |
| 101 | } |
| 102 | |
| 103 | if (!this[kHasWritePermission]()) { |
| 104 | ReplHistory[kWriteToOutput]( |
| 105 | this[kContext], |
| 106 | '\nAccess to FileSystemWrite is restricted.\n' + |
| 107 | 'REPL session history will not be persisted.\n', |
| 108 | ); |
| 109 | return onReadyCallback(null, this[kContext]); |
| 110 | } |
| 111 | |
| 112 | this[kContext].pause(); |
| 113 | |
| 114 | this[kInitializeHistory](onReadyCallback).catch((err) => { |
| 115 | this[kHandleHistoryInitError](err, onReadyCallback); |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | addHistory(isMultiline, lastCommandErrored) { |
| 120 | const line = this[kContext].line; |
no test coverage detected