arturadib/shelljs — pull request #137 by piranna (2014-06-29 22:04:24+00:00)
Title: Use inspect() to show a list in console instead of raw array object

As shown on http://nodejs.org/api/util.html#util_customizing_util_inspect_colors, objects can has a ```inspect()``` method that will be used by ```util.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:

```Javascript
> require('./global')
{}
> var a = ls()
undefined
> a
LICENSE
README.md
bin
global.js
make.js
package.json
scripts
shell.js
src
test
> a instanceof Array
true
> a.join()
'LICENSE,README.md,bin,global.js,make.js,package.json,scripts,shell.js,src,test'
> a.inspect
[Function: inspect]
> a.inspect()
'LICENSE\nREADME.md\nbin\nglobal.js\nmake.js\npackage.json\nscripts\nshell.js\nsrc\ntest'
> JSON.stringify(a)
'["LICENSE","README.md","bin","global.js","make.js","package.json","scripts","shell.js","src","test"]'
```

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 is ```grep()```, where it's currently returning a [multiline string](https://github.com/arturadib/shelljs/blob/master/src/grep.js#L46) while it could be better to return an array (with ```inspect()``` method) instead as ```ls()``` does.

I'm using ```Object.defineProperty()``` to set ```inspect()``` so it doesn't became an enumerable property.