Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

args-manager

rogerbf17MIT2.0.1

manage arguments used in .spawn(), .execFile() and their siblings

spawn, spawnSync, execFile, execFileSync, fork, child_process, arguments, args

readme

args-manager

Manage arguments used in .spawn(), .execFile() and their siblings.

usage

import createManager from 'args-manager'

const args = createManager()

args.add({ SocksPort: 9050 })
args.add({ Name: `Two Forks` })
args.add(`--start`)

args()
// [`SocksPort`, 9050, `Name`, `Two Forks`, `--start`]

args.clear()
args()
// []

options

const args = createManager({
  args: [`SocksPort`, 9050, { Lookout: `Thorofare` }],
  validArgs: (
    fs.execFileSync(`tor`, [`--list-torrc-options`])
    .trim()
    .split(`\n`)
  ),
  build: (args) => args,
  validate: (validArgs, arg) => {
    if (typeof (arg) === `string`) {
      return arg
    } else {
      throw new Error(`expected arg to be a string`)
    }
  }
})