1.0.2 • Published 3 years ago
string2argv v1.0.2
string2argv
Parse a string into an argument array, do the job like process.argv for us.
This is a fork from string-argv, changes in this fork:
- rename package to
string2argv. - export extra
string2argv&str2argvaliases. - change
export { xx as default }toexport default xx. - compatible with both ESM and CJS (by the change above).
Usage
ESM
import { string2argv } from 'string2argv'
const commandLineString = 'echo a b c -rvf --name "demo name"'
// output: [ 'echo', 'a', 'b', 'c', '-rvf', '--name', 'demo name' ]
console.log(string2argv(commandLineString))CJS
const { default: string2argv } = require('string2argv')
const commandLineString = 'echo a b c -rvf --name "demo name"'
// output: [ 'echo', 'a', 'b', 'c', '-rvf', '--name', 'demo name' ]
console.log(string2argv(commandLineString))