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 d480667

Browse filesBrowse files
princejwesleyMyles Borins
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 06113b8 commit d480667
Copy full SHA for d480667

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
@@ -1059,6 +1059,9 @@ function defineDefaultCommands(repl) {
10591059
self.write(line + '\n');
10601060
}
10611061
});
1062+
} else {
1063+
this.outputStream.write('Failed to load:' + file +
1064+
' is not a valid file\n');
10621065
}
10631066
} catch (e) {
10641067
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
@@ -76,6 +76,14 @@ putIn.write = function(data) {
7676
};
7777
putIn.run(['.load ' + loadFile]);
7878

79+
// throw error on loading directory
80+
loadFile = common.tmpDir;
81+
putIn.write = function(data) {
82+
assert.equal(data, 'Failed to load:' + loadFile + ' is not a valid file\n');
83+
putIn.write = function() {};
84+
};
85+
putIn.run(['.load ' + loadFile]);
86+
7987
// clear the REPL
8088
putIn.run(['.clear']);
8189

0 commit comments

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