Use inspect() to show a list in console instead of raw array object#137
Use inspect() to show a list in console instead of raw array object#137piranna wants to merge 8 commits intoshelljs:masterfrom
Conversation
|
I've added the inspect() method to the output of other commands including |
|
@ariporad what are your thoughts? I like the idea of having @piranna the colors definitely rock though! The only significant one missing from @piranna would you be interested in refactoring this into several smaller PRs? I think |
|
Yeah. I'm not sure about the inspect bit... It could be confusing to some people. |
|
@ariporad I don't think we can merge this as-is, because it implements too many things. @piranna I'd really like to merge some of these features, but I would need them to be done in separate PRs. If you or anyone else would like to refactor some of these features into separate PRs, that would be very appreciated. |
When used on interactive REPL it matters, specially with the
Colors come from the
I started Coreutils.js, my own implementation on the Unix commands using streams of objects instead of arrays. I think this is fairly a better approach to that problem.
You can cherry pick the parts you are interested about, but definitely I think |
|
@ariporad I vote to put off adding |
|
@nfischer: SGTM. |
|
@nfischer: I vote we close this pull request, because it's really tied to the current |
|
SGTM |
As shown on http://nodejs.org/api/util.html#util_customizing_util_inspect_colors, objects can has a
inspect()method that will be used byutil.inspect()on the Node.js REPL, so we can show on the console an output more similar to the actual one on the shell, while still returning the actual array so it can be used by other functions:I've only apply this to the array returned by
ls(), but it could be done in some other places. A good candidate to do so isgrep(), where it's currently returning a multiline string while it could be better to return an array (withinspect()method) instead asls()does.I'm using
Object.defineProperty()to setinspect()so it doesn't became an enumerable property.