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

argv-split

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argv-split - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

29

index.js
'use strict'
module.exports = split
split.join = join
// Flags Characters

@@ -72,3 +68,3 @@ // 0 1 2 3 4 5

const WHITE_SPACE = ' '
const CARRIAGE_RETURN = '\n'
const LINE_FEED = '\n'

@@ -87,3 +83,3 @@ function x () {

[WHITE_SPACE]: 4,
[CARRIAGE_RETURN]: 5
[LINE_FEED]: 5
}

@@ -210,3 +206,6 @@

const REGEX_NEED_QUOTE = /\s|"|'/
const CLI_LINE_FEED = '\\\n'
const LF = Symbol.for('argv-split:LF')
function join(args, {

@@ -235,3 +234,19 @@ quote = DOUBLE_QUOTE

return args.map(process_arg).join(WHITE_SPACE)
let joined = ''
for (const arg of args) {
if (arg === LF) {
joined += CLI_LINE_FEED
continue
}
joined += process_arg(arg) + WHITE_SPACE
}
return joined.trimRight()
}
module.exports = split
split.join = join
split.LF = LF
{
"name": "argv-split",
"version": "3.1.0",
"version": "3.2.0",
"description": "Split argv(argument vector) and handle special cases, such as quoted values.",

@@ -5,0 +5,0 @@ "files": [

@@ -96,4 +96,6 @@ [![Build Status](https://github.com/kaelzhang/node-argv-split/actions/workflows/nodejs.yml/badge.svg)](https://github.com/kaelzhang/node-argv-split/actions/workflows/nodejs.yml)

### split(string) -> Array<string>
# Methods
## split(string) -> Array<string>
Splits a string, and balance quoted parts. The usage is quite simple, see examples above.

@@ -104,3 +106,3 @@

### split.join(args, options?) -> string
## split.join(args, options?) -> string

@@ -121,4 +123,15 @@ Join the given array of argument vectors into a valid argument string

### Handle Line Feed
There is a special value of `split.LF` which could help us to create valid commands with line feeds:
```js
'kubectl' + join(['apply', '--prune', '-f', 'manifest.yaml', split.LF, '-l', 'app=nginx'])
// kubectl apply --prune -f manifest.yaml \
// -l app=nginx
```
## License
MIT
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