Conversation
lib/repl.js
Outdated
|
I found the |
|
I find it a bit redundant there, especially because |
|
… good point, I should probably get used to having to do LGTM |
lib/repl.js
Outdated
There was a problem hiding this comment.
Wait, doesn't it fail?
> ' '.repeat(-1)
RangeError: Invalid count value
There was a problem hiding this comment.
Yes, it will fail once we add a command with more than 10 characters. The longest right now is editor. Do you think that warrants a safeguard for future additions?
There was a problem hiding this comment.
Oh, I see that should actually be 9 - name.length. Fixing that.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/4030/ @princejwesley noticed you print at the start of editor mode. Would you object to me changing it to so it's more in line with the ^C message? |
|
@silverwind IMHO, |
|
@princejwesley okay let's keep it new CI: https://ci.nodejs.org/job/node-test-pull-request/4031/ |
|
@silverwind For the |
213394f to
93b3d8b
Compare
lib/repl.js
Outdated
There was a problem hiding this comment.
If the length is equal to 9, then there will be no space. Why not just
const spaces = ' '.repeat(Math.max(9 - name.length, 1));There was a problem hiding this comment.
@silverwind Find the max length programmatically. User defined commands may have bigger name 😄
There was a problem hiding this comment.
Eh, I guess why not :)
- Added dots to printed commands - Use spaces instead of tabs so there's no misalignment on terminals with a tab size other than 4 - Improved the help text for .editor and .help PR-URL: nodejs#8519
93b3d8b to
82afbbb
Compare
|
@princejwesley, @thefourtheye done and done Also fixed a test. New CI: https://ci.nodejs.org/job/node-test-pull-request/4032/ |
|
@silverwind I think you missed my last comment. User defined commands may have bigger name. find the max length programmatically. |
|
@princejwesley Done. The amount of spaces is now calculated based on the longest command, ensuring a minimum of three spaces. |
| @@ -1262,7 +1262,7 @@ function defineDefaultCommands(repl) { | |||
| const names = Object.keys(this.commands).sort(); | |||
| const longestNameLength = names.reduce((max, name) => { | |||
| return Math.max(max, name.length); | |||
There was a problem hiding this comment.
@silverwind (max, name) => Math.max(max, name.length) ? is it against style guide?
There was a problem hiding this comment.
It's not, but it won't fit on 80 chars so I went with the longer form.
There was a problem hiding this comment.
Why not named function? Feel free to ignore it
const maxFun = (max, name) => Math.max(max, name.length);
const longestNameLength = names.reduce(maxFun, 0);or
const nameLengthList = names.map((n) => n.length);
const longestNameLength = nameLengthList.reduce(Math.max, 0);There was a problem hiding this comment.
TBH, I find that these reduce readability as compared to what I have now.
|
LGTM. I like this new github interface |
- Added dots to printed commands. - Use spaces instead of tabs so there's no misalignment on terminals with a tab size other than 4. - Improved the help text for .editor and .help. - Automatically indent command help based on the longest command. PR-URL: #8519 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
|
Thanks, landed in 39fbb5a. |
- Added dots to printed commands. - Use spaces instead of tabs so there's no misalignment on terminals with a tab size other than 4. - Improved the help text for .editor and .help. - Automatically indent command help based on the longest command. PR-URL: #8519 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
repl
Description of change
.helpprint.editorBefore:
After: