Commit db0e906
repl: Fixed node repl history edge case.
If the deprecated NODE_REPL_HISTORY_FILE is set to default
node history file path ($HOME/.node_repl_history) and the file
doesn't exist, then node creates the file and then crashes when
it tries to parse that file as JSON thinking that it's an older
JSON formatted history file. This fixes that bug.
This patch also prevents node repl from throwing if the old
history file is empty or if $HOME/.node_repl_history is empty.
Fixes: #4102
PR-URL: #4108
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>1 parent 4856420 commit db0e906Copy full SHA for db0e906
File tree
Expand file treeCollapse file tree
3 files changed
+31
-3
lines changedOpen diff view settings
Filter options
- lib/internal
- test
- fixtures
- parallel
Expand file treeCollapse file tree
3 files changed
+31
-3
lines changedOpen diff view settings
Collapse file
+16-2Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
120 | 120 | |
121 | 121 | |
122 | 122 | |
123 | | - |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
124 | 132 | |
125 | 133 | |
126 | 134 | |
127 | 135 | |
128 | 136 | |
129 | 137 | |
130 | 138 | |
131 | | - |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
132 | 146 | |
133 | 147 | |
134 | 148 | |
|
Collapse file
test/fixtures/.empty-repl-history-file
Copy file name to clipboardExpand all lines: test/fixtures/.empty-repl-history-fileWhitespace-only changes.
Collapse file
test/parallel/test-repl-persistent-history.js
Copy file name to clipboardExpand all lines: test/parallel/test-repl-persistent-history.js+15-1Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
65 | 65 | |
66 | 66 | |
67 | 67 | |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
68 | 72 | |
69 | 73 | |
70 | 74 | |
71 | 75 | |
72 | 76 | |
73 | 77 | |
74 | 78 | |
| 79 | + |
75 | 80 | |
76 | 81 | |
77 | | - |
78 | 82 | |
79 | 83 | |
80 | 84 | |
| ||
92 | 96 | |
93 | 97 | |
94 | 98 | |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
95 | 109 | |
96 | 110 | |
97 | 111 | |
|
0 commit comments