0.3.2 • Published 2 months ago

extract-from-argv v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

extract-from-argv

Extracts arguments that were passed when the Node.js process was launched.

Usage

Pass arguments to the node process and read it

node my-script.js --port=4200

const port = extractFromArgv('--port'); // Returns '4200'

Custom separator

node my-script.js --port:4200

const port = extractFromArgv('--port', { valueSeparator: ':' }); // Returns '4200'

Custom argv object

const port = extractFromArgv('--port', { argv: ['/usr/node', '--port=5000'] }); // Returns '5000'

Arguments without values

node my-script.js --fun-mode

// If an argument without an value is found it returns an empty string
extractFromArgv('--fun-mode'); // Returns ''

// If a argument was not found the function returns null
extractFromArgv('--angry-mode'); // Returns null'
0.3.2

2 months ago

0.3.1

2 months ago

0.3.0

2 months ago

0.1.0

4 months ago

0.0.2

7 months ago

0.0.1

7 months ago