@anycli/parser
Advanced tools
Comparing version 3.0.4 to 3.1.0
@@ -0,1 +1,9 @@ | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/anycli/parser/compare/b5a7d6d5e4df2f270a900f83e01b8ac7836cd556...v3.1.0) (2018-02-03) | ||
### Features | ||
* added env to flags ([56be8c8](https://github.com/anycli/parser/commit/56be8c8)) | ||
<a name="3.0.4"></a> | ||
@@ -2,0 +10,0 @@ ## [3.0.4](https://github.com/anycli/parser/compare/6a33b0633c9e422b18ec33d9a1dd4202c97adf28...v3.0.4) (2018-02-01) |
@@ -14,2 +14,6 @@ import { AlphabetLowercase, AlphabetUppercase } from './alphabet'; | ||
required?: boolean; | ||
/** | ||
* also accept an environment variable as input | ||
*/ | ||
env?: string; | ||
parse(input: I): T; | ||
@@ -16,0 +20,0 @@ }; |
@@ -153,11 +153,16 @@ "use strict"; | ||
const flag = this.input.flags[k]; | ||
if (flags[k]) | ||
if (flags[k] || flag.type !== 'option') | ||
continue; | ||
if (flag.type !== 'option' || !flag.default) | ||
continue; | ||
if (typeof flag.default === 'function') { | ||
flags[k] = flag.default({ options: flag, flags }); | ||
if (flag.env) { | ||
let input = process.env[flag.env]; | ||
if (input) | ||
flags[k] = flag.parse(input); | ||
} | ||
else { | ||
flags[k] = flag.default; | ||
if (!flags[k] && flag.default) { | ||
if (typeof flag.default === 'function') { | ||
flags[k] = flag.default({ options: flag, flags }); | ||
} | ||
else { | ||
flags[k] = flag.default; | ||
} | ||
} | ||
@@ -164,0 +169,0 @@ } |
{ | ||
"name": "@anycli/parser", | ||
"description": "arg and flag parser for anycli", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/anycli/parser/issues", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
30860
708
4