Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable using a function "file" to read file content directly on .env file #429

Closed
jjangga0214 opened this issue Oct 14, 2019 · 1 comment

Comments

@jjangga0214
Copy link

jjangga0214 commented Oct 14, 2019

It has been inconvenient specifying very long value which originally should be contained in a file (e.g. private/public keys). There also have been requests for easier multiline use (e.g. #196).

Therefore I suggest a built-in function, file.

FOO=foo
BAR=bar
PRIVATE_KEY=file(path/to/file)

This would read file content from the given path (argument).

No more manually making a multiline value to single line, and replacing \\n to \n.

Maybe we can generalize the idea to enable other functions if desired. For example, special characters indicating a function like #function# or $function$.

@maxbeatty
Copy link
Contributor

Yes, I agree it makes more sense to store (very) long values in separate files instead of manually altering them to a single line in .env files. Instead of creating new syntax to be interpreted by dotenv, you could just use Node.js.

PRIVATE_KEY_PATH=path/to/file
require("dotenv").config()

process.env.PRIVATE_KEY = require("fs").readFileSync(process.env.PRIVATE_KEY_PATH)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants