-
Notifications
You must be signed in to change notification settings - Fork 24
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
Only return vars present in schema / filter out vars not in schema from (load
) result?
#49
Comments
@emme1444 you should be able to do something like this: const myConfig = require('dotenv-extended').load(); in this example, Let me know if that helps. |
@keithmorris I sincerely apologize for my lack of specificity on the subject. My options object looks more like the following: dotenvExtended.load({
encoding: "utf-8",
path: ".env",
defaults: ".env.defaults",
schema: ".env.schema",
errorOnExtra: true,
errorOnMissing: true,
errorOnRegex: true,
assignToProcessEnv: false,
includeProcessEnv: true,
}); So if I may rephrase my question; how would I go about doing what is discussed with the above options? (namely If I understand correcly, setting Again, I apologize for not being specific enough, and thank you for your time! |
@emme1444 I'm not sure I fully understand your question. It sounds like when using the library as you describe above, you want The only way you can get just the items in your const myEnvVariables = dotenvExtended.load({
encoding: "utf-8",
path: ".env",
defaults: ".env.defaults",
schema: ".env.schema",
errorOnExtra: true,
errorOnMissing: true,
errorOnRegex: true,
assignToProcessEnv: false,
includeProcessEnv: true,
}); Now you should be able to use the variables from the The Let me know if that helps. |
Hey @keithmorris! I apologize again! I'll do my best to describe my problem. This time with sufficient examples.
Actually, what I'd like is for the return value of You say:
The problem is that when setting Here is a simple example of the above statement: const dotenvExtended = require("dotenv-extended");
const parsedEnv = dotenvExtended.load({
errorOnExtra: true,
errorOnMissing: true,
errorOnRegex: true,
assignToProcessEnv: false,
includeProcessEnv: false,
});
parsedEnv === {
API_URL: 'hello'
}; The only problem with the above example is that const dotenvExtended = require("dotenv-extended");
const parsedEnv = dotenvExtended.load({
errorOnExtra: true,
errorOnMissing: true,
errorOnRegex: true,
assignToProcessEnv: false,
includeProcessEnv: true,
});
parsedEnv === {
API_URL: 'hello',
PATH: '...',
PS1: '\\e[0;36m\\w\\e[0;32m \\e[0;35m$\\e[m ',
TMP: 'C:\\Users\\user\\AppData\\Local\\Temp',
USERNAME: 'user',
// etc...
}; Hmm...? Now the returned object contains all the variables present in the My question then is: How would I go about filtering out these variables ( I hope this helps illustrate my problem. And I again apologize for taking your time. Thank you so much!
|
How would I go about filtering out all variables coming from the system, that is not present in the
.schema
file. i.e. those I do not need in my app, pretty much.Thanks!
The text was updated successfully, but these errors were encountered: