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

spawn-args

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spawn-args

Turn a string of command line options into an array for child_process.spawn

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
147K
increased by1.26%
Maintainers
1
Weekly downloads
 
Created

What is spawn-args?

The spawn-args npm package is used to parse command-line arguments into an array that can be passed to child_process.spawn in Node.js. This is particularly useful for executing shell commands programmatically.

What are spawn-args's main functionalities?

Basic Argument Parsing

This feature allows you to parse a command-line string into an array of arguments. This array can then be used with child_process.spawn to execute the command.

const spawnArgs = require('spawn-args');
const args = spawnArgs('ls -la /usr/local');
console.log(args); // Output: ['ls', '-la', '/usr/local']

Handling Quoted Strings

This feature handles quoted strings correctly, ensuring that arguments containing spaces are treated as a single argument.

const spawnArgs = require('spawn-args');
const args = spawnArgs('echo "Hello World"');
console.log(args); // Output: ['echo', 'Hello World']

Custom Delimiters

This feature allows you to specify a custom delimiter for separating arguments, which can be useful for parsing non-standard command-line formats.

const spawnArgs = require('spawn-args');
const args = spawnArgs('command arg1,arg2,arg3', { delimiter: ',' });
console.log(args); // Output: ['command', 'arg1', 'arg2', 'arg3']

Other packages similar to spawn-args

Keywords

FAQs

Package last updated on 30 Jun 2016

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