Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
A very basic module that only runs code if the script is ran directly (e.g. calling node script
). It will not call the code if the script has been required (e.g. require('script')
).
node-main utilizes optimist for argument parsing.
npm install main
Once required, you can chain the functions below
options
follows the optimist format for options, but groups them together, e.g.:
require('main').flags({
f: { alias: 'flag' },
t: { alias: 'secondFlag' },
d: { demand: true },
// ...
})
fn
is the callback that will be invoked when the script is ran directly from a terminal. It can take the following parameters:
fn(argv, exit)
argv
is the parsed optimist argv objectexit
is a helper function that can be used to exit the script. It follows the form exit(exitCode, optionalMessage)
. If no exit code if provided, it will exit with 0 (success).#!/usr/bin/env node
exports.isTrue = function(value) { // just to get a point across...
return value === true;
};
require('main')
.flags({
v: { alias: 'valid', 'boolean': true, 'default': false }
})
.run(function(argv, exit) {
if (exports.isTrue(argv.valid)) {
exit();
} else {
exit(1, 'optional error message');
}
});
Running from the terminal ($? indicates exit status):
> node scriptAbove.js --valid
> $?
0
> node scriptAbove.js
optional error message
> $?
1
Using the module from another script will not execute the code in main:
var scriptAbove = require('./scriptAbove');
console.log(scriptAbove.valid('hello')); // 'false'
console.log(scriptAbove.valid(true)); // 'true'
FAQs
main entry point
The npm package main receives a total of 0 weekly downloads. As such, main popularity was classified as not popular.
We found that main demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.