Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aad6b9f

Browse filesBrowse files
princejwesleyJungMinu
authored andcommitted
repl: display error message when loading directory
When loading directory instead of file, no error message is displayed. It's good to display error message for this scenario. PR-URL: #4170 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
1 parent 67e1819 commit aad6b9f
Copy full SHA for aad6b9f

File tree

Expand file treeCollapse file tree

2 files changed

+11
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-0
lines changed
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ function defineDefaultCommands(repl) {
10821082
self.write(line + '\n');
10831083
}
10841084
});
1085+
} else {
1086+
this.outputStream.write('Failed to load:' + file +
1087+
' is not a valid file\n');
10851088
}
10861089
} catch (e) {
10871090
this.outputStream.write('Failed to load:' + file + '\n');
Collapse file

‎test/parallel/test-repl-.save.load.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-.save.load.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ putIn.write = function(data) {
6161
};
6262
putIn.run(['.load ' + loadFile]);
6363

64+
// throw error on loading directory
65+
loadFile = common.tmpDir;
66+
putIn.write = function(data) {
67+
assert.equal(data, 'Failed to load:' + loadFile + ' is not a valid file\n');
68+
putIn.write = function() {};
69+
};
70+
putIn.run(['.load ' + loadFile]);
71+
6472
// clear the REPL
6573
putIn.run(['.clear']);
6674

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.