Skip to content

Commit 318ff7b

Browse files
watsonianijjk
andauthored
Support named pipes when loading .env files (#70725)
### What? Updates `@next/env` to support loading `.env` "files" that are named pipes. ### Why? Some third party secret managers (like [Doppler](https://docs.doppler.com/docs/accessing-secrets#mounting)) have CLIs that can "mount" a `.env` file. This "file" is actually a named pipe, which prevents the secrets from being stored on disk, but otherwise acts exactly like a file. The check in `@next/env` prevents this from working because `isFile()` returns false for named pipes. ### How? When loading potential `.env` files, an `fs.statSync()` is performed and then `isFile()` is called. If that's false, the potential file is skipped. This includes named pipes. The change is very simple and just updates the check so it looks at `isFile()` _and_ `isFIFO()`, which returns true for named pipes. Co-authored-by: JJ Kasper <[email protected]>
1 parent ffc326c commit 318ff7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/next-env/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ export function loadEnvConfig(
148148
try {
149149
const stats = fs.statSync(dotEnvPath)
150150

151-
// make sure to only attempt to read files
152-
if (!stats.isFile()) {
151+
// make sure to only attempt to read files or named pipes
152+
if (!stats.isFile() && !stats.isFIFO()) {
153153
continue
154154
}
155155

0 commit comments

Comments
 (0)