Socket
Socket
Sign inDemoInstall

main

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

main - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

examples/positionalOnly.js

5

package.json
{
"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",

12

README.md

@@ -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 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc