+41
-4
| #!/usr/bin/env node | ||
| let fs = require('fs'); | ||
| let crypto = require('crypto'); | ||
@@ -31,10 +32,46 @@ // | ||
| // | ||
| // 1. Chop the description in to a specific line length | ||
| // 1. Save the default value in a clear variable | ||
| // | ||
| let comment = limit_80_array(parsed[env_var].description, "", 80); | ||
| let value = parsed[env_var].value; | ||
| // | ||
| // 2. Combine the comment section with the environment variable | ||
| // 2. Save the description in a clear variable | ||
| // | ||
| line += comment + "\n" + env_var + "=\n\n" | ||
| let description = parsed[env_var].description; | ||
| // | ||
| // 3. Save the generator in a clear variable | ||
| // | ||
| let generator = parsed[env_var].generator; | ||
| // | ||
| // 4. Chop the description in to a specific line length | ||
| // | ||
| let comment = limit_80_array(description, "", 80); | ||
| // | ||
| // 5. Create the default empty env name | ||
| // | ||
| let env_name = env_var + "="; | ||
| // | ||
| // 6. If the file specifies a secret, we create one. | ||
| // | ||
| if(!value && generator === "secret") | ||
| { | ||
| env_name += crypto.randomBytes(16).toString('hex'); | ||
| } | ||
| // | ||
| // 7. If there is a default value for the env var, we append it | ||
| // | ||
| if(value && !generator) | ||
| { | ||
| env_name += value; | ||
| } | ||
| // | ||
| // 8. Combine the comment section with the environment variable | ||
| // | ||
| line += comment + "\n" + env_name + "\n\n"; | ||
| } | ||
@@ -41,0 +78,0 @@ |
+1
-1
| { | ||
| "name": "env-auto", | ||
| "version": "1.3.1", | ||
| "version": "1.4.0", | ||
| "description": "convert app.json in to .env", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+2
-2
@@ -57,3 +57,3 @@ # Why this code? | ||
| # Vivamus scelerisque placerat urna nec ultrices. Nunc ac dictum tellus. | ||
| NPM_CONFIG_PRODUCTION= | ||
| NPM_CONFIG_PRODUCTION=true | ||
@@ -67,3 +67,3 @@ # Quisque justo odio, pretium a ante ac, mattis pharetra lectus. Cras erat | ||
| # est pretium nec. | ||
| API_KEY= | ||
| API_KEY=5db712b385afeacaa1ab2bcaba271483 | ||
| ``` | ||
@@ -70,0 +70,0 @@ As you can see, the description will be nicely formatted; the variable will be ready to use. |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10754
7.68%174
21.68%