Unverified Commit 318ff7b6 authored by Joel Watson's avatar Joel Watson Committed by GitHub

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: 's avatarJJ Kasper <jj@jjsweb.site>
parent ffc326c6
......@@ -148,8 +148,8 @@ export function loadEnvConfig(
try {
const stats = fs.statSync(dotEnvPath)
// make sure to only attempt to read files
if (!stats.isFile()) {
// make sure to only attempt to read files or named pipes
if (!stats.isFile() && !stats.isFIFO()) {
continue
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment