Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b187d16
src: externalized messages support, 2nd pass
jasnell Jan 7, 2016
6401743
src: externalize debugger.js messages
jasnell Jan 8, 2016
3fcddc4
src: externalized _debug_agent.js messages
jasnell Jan 8, 2016
503092e
test, src: add test-internal-messages.js, address nits
jasnell Jan 8, 2016
4359ec9
src: fix lint issue
jasnell Jan 8, 2016
c48ec49
src: externalize lib/_http_agent.js messages
jasnell Jan 8, 2016
112b084
src: externalize _http_client.js messages
jasnell Jan 8, 2016
8538841
src: externalize _http_outgoing.js messages, address nits
jasnell Jan 8, 2016
ff170ed
src: remove NODE_ prefix from message identifiers
jasnell Jan 8, 2016
bdca377
src: externalize _http_server.js messages
jasnell Jan 8, 2016
b270571
src: externalize _linklist.js messages
jasnell Jan 8, 2016
1b1e228
src: externalize _stream_readable.js messages
jasnell Jan 8, 2016
ee2228d
src: externalize _stream_transform.js messages
jasnell Jan 8, 2016
71d1fae
src: externalize _stream_wrap.js messages
jasnell Jan 8, 2016
eb882bc
src: externalized _stream_writable.js messages
jasnell Jan 8, 2016
0de2994
tools: enable restParams for eslint
jasnell Jan 8, 2016
0f0298e
src: externalize _tls_legacy.js messages, refactor debug
jasnell Jan 8, 2016
f095579
src: externalize _tls_wrap.js messages
jasnell Jan 9, 2016
62f6ec9
src: externalize assert.js messages
jasnell Jan 9, 2016
5d73fb3
src: externalize buffer.js messages
jasnell Jan 9, 2016
b1bc41f
src: externalize child-process.js messages
jasnell Jan 9, 2016
018472b
src: externalize cluster.js messages
jasnell Jan 9, 2016
7aa5d4f
src: externalize console.js messages
jasnell Jan 9, 2016
20640e8
src: externalize crypto.js messages
jasnell Jan 9, 2016
78b9090
src: externalize dgram.js messages
jasnell Jan 9, 2016
82679a5
src: externalize dns.js messages
jasnell Jan 9, 2016
649721b
src: externalize events.js messages
jasnell Jan 9, 2016
11b96dc
src: externalize fs.js messages
jasnell Jan 9, 2016
abc08a9
src: externalize http.js messages
jasnell Jan 9, 2016
0b9c3af
src: externalize https.js messages
jasnell Jan 9, 2016
0e8b40a
src: externalize module.js messages
jasnell Jan 9, 2016
650ab1c
src: externalize net.js messages
jasnell Jan 9, 2016
d89c414
src: externalize os.js messages
jasnell Jan 9, 2016
181e5c6
src: externalize path.js messages
jasnell Jan 9, 2016
b1ca5e1
src: externalize punycode.js messages
jasnell Jan 9, 2016
55fa5d8
src: externalize readline.js messages
jasnell Jan 9, 2016
5f4861d
src: externalize repl.js messages
jasnell Jan 9, 2016
67185ec
src: externalize string_decoder.js messages
jasnell Jan 9, 2016
f0c5782
src: externalize sys.js messages
jasnell Jan 9, 2016
497329f
src: externalized timers.js messages
jasnell Jan 9, 2016
e142e8a
src: externalize tls.js messages
jasnell Jan 9, 2016
678e8e8
src: externalize url.js messages
jasnell Jan 9, 2016
0a197c8
src: externalize util.js messages
jasnell Jan 9, 2016
cd4db97
src: externalize zlib.js messages
jasnell Jan 9, 2016
61240ea
src: externalize internal/child_process.js messages
jasnell Jan 9, 2016
259a36d
src: externalize internal/repl.js messages
jasnell Jan 9, 2016
96aa61f
src: externalize internal/socket_list.js messages
jasnell Jan 9, 2016
b885af3
src: externalize internal/v8_prof_polyfill.js messages
jasnell Jan 9, 2016
924aa9d
src: externalize additional messages missed
jasnell Jan 9, 2016
086bd73
src: avoid runtime calls
jasnell Jan 9, 2016
46fcb2d
src: code cleanup
jasnell Jan 9, 2016
edcb53b
src: refactor I18N.Error, I18N.TypeError and I18N.RangeError
jasnell Jan 10, 2016
42b7c7f
src: internal/messages.js code cleanup
jasnell Jan 10, 2016
21b1d95
src: begin externalizing src/* messages
jasnell Jan 10, 2016
5545855
src: externalize more native strings
jasnell Jan 11, 2016
08866a3
src: support varargs in messages, externalize src/node_dtrace.cc
jasnell Jan 11, 2016
44cc074
src: refactor macros to make env explicit, externalize node_file.cc
jasnell Jan 11, 2016
a5d97de
src: externalize additional src/*.cc files
jasnell Jan 11, 2016
9fc6ec1
src: externalize remaining errors in src/*.cc
jasnell Jan 11, 2016
92df8e6
src: externalize node.cc messages and print help, cleanups
jasnell Jan 11, 2016
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
Prev Previous commit
Next Next commit
src: externalize internal/repl.js messages
  • Loading branch information
jasnell committed Jan 11, 2016
commit 259a36d145b6b26aed8927626ef46660b38c5d99
27 changes: 10 additions & 17 deletions lib/internal/repl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

const I18N = require('internal/messages');
const debug = require('util').debuglog('repl');
const Interface = require('readline').Interface;
const REPL = require('repl');
const path = require('path');
const fs = require('fs');
const os = require('os');
const debug = require('util').debuglog('repl');

module.exports = Object.create(REPL);
module.exports.createInternalRepl = createRepl;
Expand Down Expand Up @@ -68,8 +69,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
try {
historyPath = path.join(os.homedir(), '.node_repl_history');
} catch (err) {
repl._writeToOutput('\nError: Could not get the home directory.\n' +
'REPL session history will not be persisted.\n');
repl._writeToOutput(`\n${I18N(I18N.REPL_HOME_DIRECTORY)}\n`);
repl._refreshLine();

debug(err.stack);
Expand All @@ -88,8 +88,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
if (err) {
// Cannot open history file.
// Don't crash, just don't persist history.
repl._writeToOutput('\nError: Could not open history file.\n' +
'REPL session history will not be persisted.\n');
repl._writeToOutput(`\n${I18N(I18N.REPL_CANNOT_OPEN_HISTORY)}\n`);
repl._refreshLine();
debug(err.stack);

Expand Down Expand Up @@ -118,15 +117,13 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
// If pre-v3.0, the user had set NODE_REPL_HISTORY_FILE to
// ~/.node_repl_history, warn the user about it and proceed.
repl._writeToOutput(
'\nThe old repl history file has the same name and location as ' +
`the new one i.e., ${historyPath} and is empty.\nUsing it as is.\n`);
`\n${I18N(I18N.REPL_HISTORY_SAME_NAME, historyPath)}\n`);
repl._refreshLine();

} else if (oldHistoryPath) {
// Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format.
repl._writeToOutput(
'\nConverting old JSON repl history to line-separated history.\n' +
`The new repl history file can be found at ${historyPath}.\n`);
`\n${I18N(I18N.REPL_CONVERTING_HISTORY, historyPath)}\n`);
repl._refreshLine();

try {
Expand All @@ -138,13 +135,13 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
if (oldReplJSONHistory) repl.history = JSON.parse(oldReplJSONHistory);

if (!Array.isArray(repl.history)) {
throw new Error('Expected array, got ' + typeof repl.history);
throw I18N.Error(I18N.INVALID_ARG_TYPE, 'repl.history', 'array');
}
repl.history = repl.history.slice(0, repl.historySize);
} catch (err) {
if (err.code !== 'ENOENT') {
return ready(
new Error(`Could not parse history data in ${oldHistoryPath}.`));
return ready(I18N.Error(I18N.REPL_CANNOT_PARSE_HISTORY,
oldHistoryPath));
}
}
}
Expand Down Expand Up @@ -206,11 +203,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {

function _replHistoryMessage() {
if (this.history.length === 0) {
this._writeToOutput(
'\nPersistent history support disabled. ' +
'Set the NODE_REPL_HISTORY environment\nvariable to ' +
'a valid, user-writable path to enable.\n'
);
this._writeToOutput(`\n${I18N(I18N.REPL_HISTORY_DISABLED)}\n`);
this._refreshLine();
}
this._historyPrev = Interface.prototype._historyPrev;
Expand Down
17 changes: 17 additions & 0 deletions src/messages/en/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,23 @@
XX(REPL_COMMAND_LOAD_FAILED_INVALID, \
"Failed to load:{0} is not a valid file") \
XX(REPL_COMMAND_LOAD_FAILED, "Failed to load:{0}") \
XX(REPL_CANNOT_PARSE_HISTORY, "Could not parse history data in {0}.") \
XX(REPL_HISTORY_DISABLED, \
"Persistent history support disabled. Set the " \
"NODE_REPL_HISTORY environment\nvariable to " \
"a valid, user-writable path to enable.") \
XX(REPL_HOME_DIRECTORY, \
"Error: Could not get the home directory.\n" \
"REPL session history will not be persisted.") \
XX(REPL_CANNOT_OPEN_HISTORY, \
"Error: Could not open history file.\n" \
"REPL session history will not be persisted.") \
XX(REPL_HISTORY_SAME_NAME, \
"The old repl history file has the same name and location as " \
"the new one i.e., {0} and is empty.\nUsing it as is.") \
XX(REPL_CONVERTING_HISTORY, \
"Converting old JSON repl history to line-separated history.\n" \
"The new repl history file can be found at {0}.") \
XX(SYS_DEPRECATED, NODE_DEPRECATE_MESSAGE("sys", "util")) \
XX(TIMERS_NON_NEGATIVE_FINITE, \
"'{0}' argument must be a non-negative finite number") \
Expand Down