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

feat: allow dotenv default expansion #34765

Merged
merged 7 commits into from Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next-env/index.ts
Expand Up @@ -2,7 +2,7 @@
import * as fs from 'fs'
import * as path from 'path'
import * as dotenv from 'dotenv'
import dotenvExpand from 'dotenv-expand'
import { expand as dotenvExpand } from 'dotenv-expand'

export type Env = { [key: string]: string }
export type LoadedEnvFiles = Array<{
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Expand Up @@ -31,6 +31,6 @@
"devDependencies": {
"@vercel/ncc": "0.33.1",
"dotenv": "10.0.0",
"dotenv-expand": "5.1.0"
"dotenv-expand": "8.0.1"
}
}
32 changes: 32 additions & 0 deletions test/development/dotenv-default-expansion/index.test.ts
@@ -0,0 +1,32 @@
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import webdriver from 'next-webdriver'

describe('Dotenv default expansion', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>{process.env.NEXT_PUBLIC_TEST}</p>
}
`,
'.env': `
NEXT_PUBLIC_TEST=\${MISSING_KEY:-default}
`,
},
dependencies: {},
})
})
afterAll(() => next.destroy())

it('should work', async () => {
const browser = await webdriver(next.appPort, '/')
const text = await browser.elementByCss('p').text()
expect(text).toBe('default')

await browser.close()
})
})
9 changes: 5 additions & 4 deletions yarn.lock
Expand Up @@ -9118,10 +9118,10 @@ dot-prop@^6.0.1:
dependencies:
is-obj "^2.0.0"

dotenv-expand@5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
dotenv-expand@8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-8.0.1.tgz#332aa17c14b12e28e2e230f8d183eecc1c014fdc"
integrity sha512-j/Ih7bIERDR5PzI89Zu8ayd3tXZ6E3dbY0ljQ9Db0K87qBO8zdLsi2dIvDHMWtjC3Yxb8XixOTHAtia0fDHRpg==

dotenv@10.0.0:
version "10.0.0"
Expand Down Expand Up @@ -14663,6 +14663,7 @@ minipass-fetch@^1.3.0, minipass-fetch@^1.3.2:
resolved "https://registry.yarnpkg.com/minipass-fetch/-/minipass-fetch-1.3.3.tgz#34c7cea038c817a8658461bf35174551dce17a0a"
integrity sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ==
dependencies:
encoding "^0.1.12"
minipass "^3.1.0"
minipass-sized "^1.0.3"
minizlib "^2.0.0"
Expand Down