Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
repl: Failed to save editor mode text in .save
Fixes: #8142
  • Loading branch information
princejwesley committed Aug 19, 2016
commit 56bebbe4385d7329080f6f1f55c0390c17f1370f
1 change: 1 addition & 0 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ function REPLServer(prompt,

if (self.editorMode) {
self.bufferedCommand += cmd + '\n';
self.memory(cmd);
return;
}

Expand Down
19 changes: 19 additions & 0 deletions test/parallel/test-repl-.save.load.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ putIn.run(['.save ' + saveFileName]);
// the file should have what I wrote
assert.equal(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + '\n');

{
// save .editor mode code
const cmds = [
'function testSave() {',
'return "saved";',
'}'
];
const putIn = new common.ArrayStream();
const replServer = repl.start('', putIn);

putIn.run(['.editor']);
putIn.run(cmds);
replServer.write('', {ctrl: true, name: 'd'});

putIn.run([`.save ${saveFileName}`]);
replServer.close();
assert.equal(fs.readFileSync(saveFileName, 'utf8'), `${cmds.join('\n')}\n`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.strictEqual() please.

}

// make sure that the REPL data is "correct"
// so when I load it back I know I'm good
testMe.complete('inner.o', function(error, data) {
Expand Down