Comparing version 0.0.6 to 0.0.7
var main = function() { | ||
var Main = function(currentModule) { | ||
// ran directly from the cli? | ||
var ranDirectly = !module.parent.parent; | ||
var ranDirectly = !currentModule.parent; | ||
// no need to load optimist if we're not going to use it. | ||
@@ -62,2 +62,4 @@ var optimist = ranDirectly ? require('optimist') : undefined; | ||
*/ | ||
module.exports = new main(); | ||
module.exports = function(currentModule) { | ||
return new Main(currentModule); | ||
}; |
{ | ||
"name": "main", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -12,6 +12,15 @@ node-main | ||
### require('main') | ||
### require('main')(module) | ||
Once required, you can chain the functions below | ||
Once required, you can chain the functions below. | ||
Note that the `module` part is required. This is to properly allow nesting of modules. e.g. | ||
- `script1` contains `require('main')(module)` | ||
- `script2` requires `script1`, and implements it's own `require('main')(module)`. | ||
We expect that when running `script2` from the command line that it will only call the main function of `script2`, and not call the main function of `script1`. | ||
For the time being, this is required until I or someone else figures out a way around it. Read the [caching section](http://nodejs.org/api/modules.html) of the Node Modules API for more information. | ||
### .usage(message) | ||
@@ -30,3 +39,3 @@ | ||
```javascript | ||
require('main').flags({ | ||
require('main')(module).flags({ | ||
f: { alias: 'flag' }, | ||
@@ -63,3 +72,3 @@ t: { alias: 'secondFlag' }, | ||
require('main') | ||
require('main')(module) | ||
.usage('Usage:\n node test.js [flags] <word1> <word2>') | ||
@@ -66,0 +75,0 @@ .flags({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24391
54
107