@dotenvx/dotenvx
Advanced tools
Comparing version 0.3.8 to 0.3.9
{ | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`", |
@@ -97,3 +97,3 @@ ![dotenvx](https://dotenvx.com/better-banner.png) | ||
RUN echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js | ||
RUN curl -sfS https://dotenvx.sh/! | bash | ||
RUN curl -fsS https://dotenvx.sh/ | sh | ||
CMD ["dotenvx", "run", "--", "echo", "Hello $HELLO"] | ||
@@ -277,10 +277,8 @@ ``` | ||
```sh | ||
curl -sfS https://dotenvx.sh/! | sh | ||
curl -fsS https://dotenvx.sh/ | sh | ||
``` | ||
Remove the `!` to install where you prefer. (the `!` downloads directly into `/usr/local/bin/`) | ||
```sh | ||
# download it to `./dotenvx` | ||
curl -sfS https://dotenvx.sh/ | sh | ||
curl -fsS https://dotenvx.sh/ | sh | ||
@@ -287,0 +285,0 @@ # check it works |
@@ -68,2 +68,4 @@ #!/usr/bin/env node | ||
const env = {} | ||
const readableFilepaths = new Set() | ||
const populated = new Set() | ||
@@ -83,3 +85,6 @@ for (const envFilepath of optionEnvFile) { | ||
logger.debug(`Populating env from ${filepath}`) | ||
main.populate(process.env, parsed, { debug: (logger.level === 'debug'), override: options.overload }) | ||
const result = main.populate(process.env, parsed, options.overload) | ||
readableFilepaths.add(envFilepath) | ||
result.populated.forEach(key => populated.add(key)) | ||
} catch (e) { | ||
@@ -90,3 +95,5 @@ logger.warn(e) | ||
logger.info('Injecting X environment variables into your application process') | ||
if (readableFilepaths.size > 0) { | ||
logger.info(`Injecting ${populated.size} environment variables from ${[...readableFilepaths]}`) | ||
} | ||
@@ -93,0 +100,0 @@ // Extract command and arguments after '--' |
@@ -16,8 +16,38 @@ const logger = require('./../shared/logger') | ||
const populate = function (processEnv, parsed, options = {}) { | ||
const result = dotenv.populate(processEnv, parsed, options = {}) | ||
const populate = function (processEnv = {}, parsed = {}, overload = false) { | ||
if (typeof parsed !== 'object') { | ||
throw new Error('OBJECT_REQUIRED: Please check the parsed argument being passed to populate') | ||
} | ||
logger.debug(process.env) | ||
const populated = new Set() | ||
const preExisting = new Set() | ||
return result | ||
// set processEnv | ||
for (const key of Object.keys(parsed)) { | ||
if (Object.prototype.hasOwnProperty.call(processEnv, key)) { | ||
if (overload === true) { | ||
processEnv[key] = parsed[key] | ||
populated.add(key) | ||
logger.verbose(`${key} set`) | ||
logger.debug(`${key} set to ${parsed[key]}`) | ||
} else { | ||
preExisting.add(key) | ||
logger.verbose(`${key} pre-exists`) | ||
logger.debug(`${key} pre-exists as ${processEnv[key]}`) | ||
} | ||
} else { | ||
processEnv[key] = parsed[key] | ||
populated.add(key) | ||
logger.verbose(`${key} set`) | ||
logger.debug(`${key} set to ${parsed[key]}`) | ||
} | ||
} | ||
return { | ||
populated, | ||
preExisting | ||
} | ||
} | ||
@@ -24,0 +54,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12553
182
5
303