| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
|
The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @anonrig. Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Can you please add a test that validates what happens when the .env file defines a NODE_OPTIONS?
Sorry, something went wrong.
There was a problem hiding this comment.
I just reviewed the docs, but 👍 to the general idea. Thanks for implementing this.
Sorry, something went wrong.
There was a problem hiding this comment.
It seems more logical to me to have it on process, since it has direct effect on process.env. An utility function would only return the parsed result without side effects
Sorry, something went wrong.
@targos Process is a global variable. Are you suggesting having process.loadEnvFile()? |
Sorry, something went wrong.
|
That's what I'm suggesting, yes. |
Sorry, something went wrong.
|
What about also adding a "register" like import which simply consists of the following file: import util from 'node:util'
util.loadEnvFile()which allows it to be used as follows: import 'node:util/load-env'Ofc load-env was just a random name I chose. It's similar to how dotenv/register works, which would ease migration to this native node way. |
Sorry, something went wrong.
I don’t think “be able to load environment variables from a file in a one-liner” is a high priority. I think we should separate out the loading from the parsing, and this should just be parseEnvFile and it can stay on util. This takes care of the other request that someone had, to be able to load multiple files. import { parseEnvFile } from 'node:util'
import { dev } from './my-environment.js'
const commonVariables = await readFile('.env', 'utf8')
const environmentSpecificVariables = await readFile(`.${dev ? 'dev' : 'prod' }.env`, 'utf8')
const parsedCommonVariables = parseEnvFile(commonVariables)
const parsedEnvironmentSpecificVariables = parseEnvFile(environmentSpecificVariables)
process.env = { ...process.env, ...parsedCommonVariables, ...parsedEnvironmentSpecificVariables } |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. I agree it makes sense to move to process
Sorry, something went wrong.
Notable changes: build: * (SEMVER-MINOR) build opt to set local location of headers (Michael Dawson) #51525 crypto: * (SEMVER-MINOR) implement crypto.hash() (Joyee Cheung) #51044 * update root certificates to NSS 3.98 (Node.js GitHub Bot) #51794 doc: * add zcbenz to collaborators (Cheng Zhao) #51812 * add lemire to collaborators (Daniel Lemire) #51572 http2: * (SEMVER-MINOR) add h2 compat support for appendHeader (Tim Perry) #51412 * (SEMVER-MINOR) add server handshake utility (snek) #51172 * (SEMVER-MINOR) receive customsettings (Marten Richter) #51323 lib: * (SEMVER-MINOR) move encodingsMap to internal/util (Joyee Cheung) #51044 sea: * (SEMVER-MINOR) support sea.getRawAsset() (Joyee Cheung) #50960 * (SEMVER-MINOR) support embedding assets (Joyee Cheung) #50960 src: * (SEMVER-MINOR) print string content better in BlobDeserializer (Joyee Cheung) #50960 * (SEMVER-MINOR) support multi-line values for .env file (IlyasShabi) #51289 * (SEMVER-MINOR) add `process.loadEnvFile` and `util.parseEnv` (Yagiz Nizipli) #51476 * (SEMVER-MINOR) do not coerce dotenv paths (Tobias Nießen) #51425 stream: * (SEMVER-MINOR) implement `min` option for `ReadableStreamBYOBReader.read` (Mattias Buelens) #50888 util: * (SEMVER-MINOR) add styleText API to text formatting (Rafael Gonzaga) #51850 vm: * (SEMVER-MINOR) support using the default loader to handle dynamic import() (Joyee Cheung) #51244 PR-URL: #51932
Notable changes: build: * (SEMVER-MINOR) build opt to set local location of headers (Michael Dawson) #51525 crypto: * (SEMVER-MINOR) implement crypto.hash() (Joyee Cheung) #51044 * update root certificates to NSS 3.98 (Node.js GitHub Bot) #51794 doc: * add zcbenz to collaborators (Cheng Zhao) #51812 * add lemire to collaborators (Daniel Lemire) #51572 http2: * (SEMVER-MINOR) add h2 compat support for appendHeader (Tim Perry) #51412 * (SEMVER-MINOR) add server handshake utility (snek) #51172 * (SEMVER-MINOR) receive customsettings (Marten Richter) #51323 lib: * (SEMVER-MINOR) move encodingsMap to internal/util (Joyee Cheung) #51044 sea: * (SEMVER-MINOR) support sea.getRawAsset() (Joyee Cheung) #50960 * (SEMVER-MINOR) support embedding assets (Joyee Cheung) #50960 src: * (SEMVER-MINOR) print string content better in BlobDeserializer (Joyee Cheung) #50960 * (SEMVER-MINOR) support multi-line values for .env file (IlyasShabi) #51289 * (SEMVER-MINOR) add `process.loadEnvFile` and `util.parseEnv` (Yagiz Nizipli) #51476 * (SEMVER-MINOR) do not coerce dotenv paths (Tobias Nießen) #51425 stream: * (SEMVER-MINOR) implement `min` option for `ReadableStreamBYOBReader.read` (Mattias Buelens) #50888 util: * (SEMVER-MINOR) add styleText API to text formatting (Rafael Gonzaga) #51850 vm: * (SEMVER-MINOR) support using the default loader to handle dynamic import() (Joyee Cheung) #51244 PR-URL: #51932
| Back | FazBrowse Home | New Git URL |
Introduces 2 new functions to use the default .env parser.
process.loadEnvFile(path)
util.parseEnv(content)
Fixes #51413
Ref #49148
Thank you Sentry for sponsoring this work!