visionmedia/commander.js — Issue #48: Take -version from package.json
Author: ypocat
Created: 2012-02-05 02:27:52+00:00
State: open

E.g.

```js
program.version(JSON.parse(require('fs').readFileSync(
require.main.filename.match(/^(.+)\/.+$/)[1] + '/../package.json')).version)
```

But a test is needed for the existence of package.json, I think the 2 most used locations are \ and \/\.

So 1, check for `main_module_dir/package.json` and 2, check for `main_module_dir/../package.json`.