Node Cli Params
Get your inline parameters in a node environment.
Options
Methods | Arguments | Description |
---|---|---|
hasKey | key | hasKey(key) - true or false |
getKey | key | getKey(key) - returns the value of a found key or false |
Example
let nodeCliParams = ; console;console;console;console; console;console;console;console; console;console;
Run
node ./YOUR_FILE_WITH_THE_ABOVE_CODE.js environment=production title="node cli params" metadata="{text: 'normal text'}"
Output:
##################
### Parameters ###
##################
{ 'which node': '',
'script file path': '',
environment: 'production',
title: 'node cli params',
metadata: '{text: \'normal text\'}' }
#######################
### Arguments found ###
#######################
[ 'which node',
'script file path',
'environment',
'title',
'metadata' ]
Has 'environment' key ? true
'environment' value = production