Make getCommandId() more readable.

This commit is contained in:
Marko Schulz
2014-06-03 22:50:25 +02:00
parent 233055a7ab
commit 9410216b02
2 changed files with 9 additions and 9 deletions

View File

@@ -120,7 +120,7 @@ addHistory = (repl, filename, maxSize) ->
repl.rli.on 'exit', -> fs.close fd
# Add a command to show the history stack
repl.commands[getCommandId(repl, '.history')] =
repl.commands[getCommandId(repl, 'history')] =
help: 'Show command history'
action: ->
repl.outputStream.write "#{repl.rli.history[..].reverse().join '\n'}\n"
@@ -128,8 +128,8 @@ addHistory = (repl, filename, maxSize) ->
getCommandId = (repl, commandName) ->
# Node 0.11 changed API, a command such as '.help' is now stored as 'help'
commandsHaveLeadingDot = ! repl.commands['help']
if commandsHaveLeadingDot then commandName else commandName[1..]
commandsHaveLeadingDot = repl.commands['.help']?
if commandsHaveLeadingDot then ".#{commandName}" else commandName
module.exports =
start: (opts = {}) ->
@@ -147,5 +147,5 @@ module.exports =
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize if opts.historyFile
# Adapt help inherited from the node REPL
repl.commands[getCommandId(repl, '.load')].help = 'Load code from a file into this REPL session'
repl.commands[getCommandId(repl, 'load')].help = 'Load code from a file into this REPL session'
repl