bigint-crypto-utils/node_modules/object-to-spawn-args
juanelas c29b520108 JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
..
example JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
lib JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
test JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
.travis.yml JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
LICENSE JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
README.md JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
package.json JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00

README.md

view on npm npm module downloads Build Status Dependency Status js-standard-style

object-to-spawn-args

Converts an options object to an array suitable for passing to child_process.spawn().

Single letter object properties (e.g. c: 'red') convert to short-option args (e.g. -c red). Longer object properties (e.g. colour: 'red') convert to long-option args (e.g. --colour red). Object property values equalling true convert to flags (e.g. -l).

This options object:

var options = {
  l: true,
  c: 'red',
  man: 'pete',
  tramp: true
}

converts to

[ '-l', '-c', 'red', '--man', 'pete', '--tramp' ]

Installation

Move into your project directory then run:

$ npm install object-to-spawn-args --save

Mac / Linux users may need to run with sudo.

Usage

var toSpawnArgs = require('object-to-spawn-args')
var spawn = require('child_process').spawn

var options = {
  l: true,
  a: true
}

spawn('ls', toSpawnArgs(options), { stdio: 'inherit' })

© 2014-17 Lloyd Brookes 75pound@gmail.com.