einars/js-beautify — pull request #334 by dertseha (2013-10-11 19:07:40+00:00)
Title: Making .jsbeautifyrc resolve work (in general and for Windows re home dir)

I've modified the cli.js file to have the resolving of .jsbeautify work actually. Not only did it not work on Windows in some cases, resolving the local .jsbeautify rc file didn't work as expected either.

Reasons re resolving issues:
* cc.find() uses __dirname internally, which resolves to its own path, somewhere in node_modules, instead of where the process was called from
* cc.find() doesn't properly work on Windows when trying to resolve a path on a different volume as the recursion aborts at the top. (I ran js-beautify on D:\ and my user home was on C:\ -- never resolved)

As a result I modified the code to
* have a dedicated resolve function. A fix in config-chain would be the alternative, but the use-case in js-beautify is a simple one
* not walk the directory tree when looking into the home folder; Doesn't make sense here.
* use either HOME or USERPROFILE environment variables for home directory to fix #300.

Here's the output from running a manual test on Windows:
```
D:\project\github\js-beautify\js\bin>set HOME & set USERPROFILE
HOME=C:\Users\myuser
HOMEDRIVE=C:
HOMEPATH=\Users\myuser
USERPROFILE=C:\Users\myuser

D:\project\github\js-beautify\js\bin>type C:\Users\myuser\.jsbeautifyrc
{
"indent_size": 10,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false
}

D:\project\github\js-beautify\js\bin>type D:\temp\test.js
function indentMe() {
"no, me!";
}

D:\project\github\js-beautify\js\bin>node js-beautify.js d:\temp\test.js
function indentMe() {
"no, me!";
}

D:\project\github\js-beautify\js\bin>set HOME=

D:\project\github\js-beautify\js\bin>node js-beautify.js d:\temp\test.js
function indentMe() {
"no, me!";
}

D:\project\github\js-beautify\js\bin>set USERPROFILE=

D:\project\github\js-beautify\js\bin>node js-beautify.js d:\temp\test.js
function indentMe() {
"no, me!";
}

```

Side note: I found it interesting that there is no .jsbeautifyrc for js-beautify itself (nor a .jshintrc for that matter) ;)