Permalink
Browse files

repl: Failed to save editor mode text in `.save`

Fixes: #8142
PR-URL: #8145
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
princejwesley committed Aug 17, 2016
1 parent ccbb3c7 commit f6a74345d1caa27209a81c7a9724db283b0fc84b
Showing with 21 additions and 0 deletions.
  1. +1 −0 lib/repl.js
  2. +20 −0 test/parallel/test-repl-.save.load.js
View
@@ -471,6 +471,7 @@ function REPLServer(prompt,
if (self.editorMode) {
self.bufferedCommand += cmd + '\n';
self.memory(cmd);
return;
}
@@ -29,6 +29,26 @@ 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.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
`${cmds.join('\n')}\n`);
}
// 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) {

0 comments on commit f6a7434

Please sign in to comment.