Browse Source

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

Fixes: https://github.com/nodejs/node/issues/8142
PR-URL: https://github.com/nodejs/node/pull/8145
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v7.x
Prince J Wesley 8 years ago
parent
commit
f6a74345d1
No known key found for this signature in database GPG Key ID: 9D76A33B02A4C46B
  1. 1
      lib/repl.js
  2. 20
      test/parallel/test-repl-.save.load.js

1
lib/repl.js

@ -471,6 +471,7 @@ function REPLServer(prompt,
if (self.editorMode) { if (self.editorMode) {
self.bufferedCommand += cmd + '\n'; self.bufferedCommand += cmd + '\n';
self.memory(cmd);
return; return;
} }

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

@ -29,6 +29,26 @@ putIn.run(['.save ' + saveFileName]);
// the file should have what I wrote // the file should have what I wrote
assert.equal(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + '\n'); 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" // make sure that the REPL data is "correct"
// so when I load it back I know I'm good // so when I load it back I know I'm good
testMe.complete('inner.o', function(error, data) { testMe.complete('inner.o', function(error, data) {

Loading…
Cancel
Save