Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "main", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
@@ -9,0 +6,0 @@ "type": "git", |
@@ -55,3 +55,3 @@ node-main | ||
### .run(fn) | ||
### `.run(fn)` | ||
@@ -74,3 +74,3 @@ `fn` is the callback that will be invoked when the script is ran directly from a terminal. It can take the following parameters: | ||
Allows easy access to positional arguments, or flag values. | ||
Allows easy access to positional arguments or flag values. | ||
@@ -119,13 +119,13 @@ ```bash | ||
#### `$.out(something)` and `$.cout(something)` | ||
#### `$.out(something)` and `$.cout(something, [arg1, arg2, ...])` | ||
Write something to standard output. `$.out` uses `process.stdout.write` and `cout` uses `console.log`. | ||
#### `$.err(something)` and `$.cerr(something)` | ||
#### `$.err(something)` and `$.cerr(something, [arg1, arg2, ...])` | ||
Write something to standard output. `$.err` uses `process.stderr.write` and `$.cerr` uses `console.error`. | ||
### `$.assert` | ||
### Assert Statements | ||
Helps with the checking basic things. If an assertion fails it will print the usage information followed by the reason the script failed and then exit with a status of 1. All assertions can be chained, e.g. | ||
Assert statements help with the checking basic things. If an assertion fails it will print the usage information followed by the reason the script failed and then exit with a status of 1. All assertions can be chained, e.g. | ||
@@ -132,0 +132,0 @@ ```javascript |
@@ -1,17 +0,17 @@ | ||
var scriptTools = require('./scriptTools'); | ||
var Tools = require('./Tools'); | ||
var Main = function(currentModule) { | ||
// ran directly? e.g. node script & not required | ||
var ranDirectly = !currentModule.parent; | ||
// script tools | ||
var tools = scriptTools(ranDirectly); | ||
var ranDirectly = !currentModule.parent | ||
, usage | ||
, flags; | ||
// sets the usage | ||
this.usage = function(message) { | ||
if (ranDirectly) { tools.updateUsage(message); } return this; | ||
this.usage = function(newUsage) { | ||
if (ranDirectly) { usage = newUsage; } return this; | ||
}; | ||
// sets the flags | ||
this.flags = function(flags) { | ||
if(ranDirectly && flags) { tools.updateFlags(flags); } return this; | ||
this.flags = function(newFlags) { | ||
if(ranDirectly && newFlags) { flags = newFlags; } return this; | ||
}; | ||
@@ -21,3 +21,7 @@ | ||
this.run = function(mainFn) { | ||
if (ranDirectly) { mainFn(tools); } | ||
if (ranDirectly) { | ||
// script tools (no need to load if not running directly) | ||
var tools = ranDirectly ? new Tools(usage, flags) : undefined; | ||
mainFn(tools); | ||
} | ||
}; | ||
@@ -24,0 +28,0 @@ }; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
11
2
14653
210