Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opt/require

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opt/require

Plugin for @opt/parse adding type def which calls require() on the value.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@opt/require

Build Status Dependency Status npm version Coverage Status

Plugin for @opt/parse adding type def which calls require() on the value.

It adds to nopt's typeDef a new type marked by the string require. When an option has that type it is tested as a path first, then, require() is called on it to get the result, which is placed into the parsed options.

Basically, you can do an option like: name: require and name: [require, Array] and you'll get back the result of the require operation in the name property.

See @opt/parse

See @opt/nopt

See @use/core

Install

npm install @opt/require --save

Usage

var parse = require('@opt/parse')

// make nopt the parser and apply our require plugin
parse.use('@opt/nopt', '@opt/require')

var options = {
  // the type def is marked with string 'require()'
  // this allows multiple of them, set into an array.
  plugin: [require, Array]
}

// an example args array with a plugin option to require()
// the module path must be absolute, or relative to CWD. or use ~/
var argv = [ 'node', 'some.js', '--plugin', 'some/module' ]

// then use parse as you would use `nopt`,
// plus any changes made possible by the plugins added
options = parse(options, {}, argv, 2)

// the above would produce:
options = {
  // can't write a function... so, 'theModuleFunction' means a real function
  // returned by require('some/module')
  plugin: [ theModuleFunction ]
  argv: {
    original: [ 'node', 'some.js', '--plugin', 'some/module' ]
    original: [ 'node', 'some.js', '--plugin', 'some/module' ]
    remain  : []
  }
}

MIT License

Keywords

FAQs

Package last updated on 04 Jan 2017

Did you know?

Socket

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.

Install

Related posts

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