| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
If we are anyway going to use the actual value as it is, then why not just
if (opts.terminal &&
typeof env.NODE_REPL_HISTORY === 'string' &&
env.NODE_REPL_HISTORY.trim() !== '') {
...
}
Sorry, something went wrong.
There was a problem hiding this comment.
Because then we would have to trim the string more than once before it is passed to setupHistory
Sorry, something went wrong.
There was a problem hiding this comment.
@evanlucas How so? We are anyway passing env.NODE_REPL_HISTORY as it is to setupHistory.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh wow. Not what I meant to do. Will fix shortly. I was meaning to pass the trimmed historyPath to setupHistory
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed
Sorry, something went wrong.
|
Hmmm, I still feel that the type checking would be better here. Because, users can tamper env programmatically and we will fail at runtime if trim is not defined on that object. |
Sorry, something went wrong.
|
process.env gets coerced to a string when set though. > process.env.test = 1
1
> process.env.test
'1'
> process.env.test = { 'name': 'test' }
{ name: 'test' }
> process.env.test
'[object Object]'
> process.env.PATH
'/Users/evan/dev/code/depot_tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin'
|
Sorry, something went wrong.
|
TIL :-) Thanks :P In that case, we can simply do const historyPath = env.NODE_REPL_HISTORY.trim();
if (historyPath) {
return setupHistory(...);
}Right? |
Sorry, something went wrong.
|
We can't do that because the key may not exist at all: > process.env.biscuits.trim()
TypeError: Cannot read property 'trim' of undefined
at repl:1:21
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
>
|
Sorry, something went wrong.
|
Ah, right. Thanks :) Change LGTM. Let's see what @Fishrock123 thinks. Apart from this, should we warn the user that the file name is an empty string? |
Sorry, something went wrong.
There was a problem hiding this comment.
All of this logic, including the check for empty string might make more sense inside of setupHistory().
Sorry, something went wrong.
|
This probably warrants a tiny documentation update to mention that whitespace is stripped. Right now it only says:
After this change, that would only be partially correct. |
Sorry, something went wrong.
|
LGTM. What do y'all think about landing this in v4? |
Sorry, something went wrong.
|
@cjihrig nits addressed. PTAL. @jasnell I think it should definitely be backported to LTS. Especially considering the problems it could cause on windows as stated in #4522 (comment) |
Sorry, something went wrong.
There was a problem hiding this comment.
This condition is not necessary. If the control reaches this point, then historyPath is not an empty string.
Sorry, something went wrong.
There was a problem hiding this comment.
It could be undefined though
Sorry, something went wrong.
|
One comment, then LGTM. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Looking, sorry for the delay. |
Sorry, something went wrong.
There was a problem hiding this comment.
Wait what else would it be? We don't export setupHistory().
Sorry, something went wrong.
There was a problem hiding this comment.
if process.env.NODE_REPL_HISTORY is undefined, then it will be undefined
Sorry, something went wrong.
There was a problem hiding this comment.
Oh right, carry on.
Sorry, something went wrong.
|
Seems fine to me. |
Sorry, something went wrong.
|
Rebased after the eslint changes. @Fishrock123 @jasnell @cjihrig @thefourtheye LGTY? |
Sorry, something went wrong.
|
Yep, still LGTM. |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
| Back | FazBrowse Home | New Git URL |
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
Related: #4522
R= @Fishrock123?