I have reworked the detection to use `package.json` as the only indicator whether a folder is an application root, see 1b343ec.

Also I am checking only the immediate parent folder of the script (works for `~/myproject/nonbin/app.js`, won't work for `~/myproject/bin/cli/app.js`).

IMO it's not worth spending too much time on this algorithm until we get feedback (i.e. bug reports) from the users.