Print each command-line argument as a line
- Node.js ≥ 6.0.0, and npm
npm install --global argv-to-list
argv-to-list first second 'This argument contains spaces'
Output: The following text would be printed to terminal screen
first
second
This argument contains spaces
Each argument is pushed to stdout seperately, that means there are each chunk of stdout for every one of them.
Example:
const arguments = ['abc\ndef\nghi\njkl', 'foo\nbar']
const {stdout} = require('child_process').spawn('argv-to-list', arguments)
const print = chunk => console.log({chunk: String(chunk)})
stdout.on('data', print)
This is the output:
{ chunk: 'abc\ndef\nghi\njkl\n' }
{ chunk: 'foo\nbar\n' }
argvToList(input = process.argv, begin = 2, end?: number): void