Skip to content

Commit a70ecff

Browse files
ryancbahanclaude
andcommitted
Fix dotenv discovery to support hyphenated config names
The regex filter in discoverDotEnvFiles used \w+ which excludes hyphens, so .env.my-staging would not be discovered for a shopify.app.my-staging.toml config. Change to [\w-]+ to match the config shorthand naming convention. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8cb70ec commit a70ecff

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

packages/app/src/cli/models/project/config-selection.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ describe('resolveDotEnv', () => {
5858
expect(dotenv).toBeUndefined()
5959
})
6060
})
61+
62+
test('returns config-specific dotenv for hyphenated config name', async () => {
63+
await inTemporaryDirectory(async (dir) => {
64+
await writeFile(joinPath(dir, '.env.my-staging'), 'KEY=my-staging')
65+
await writeFile(joinPath(dir, 'shopify.app.my-staging.toml'), 'client_id = "x"')
66+
const project = await setupProject(dir)
67+
68+
const dotenv = resolveDotEnv(project, joinPath(dir, 'shopify.app.my-staging.toml'))
69+
70+
expect(dotenv!.variables.KEY).toBe('my-staging')
71+
})
72+
})
6173
})
6274

6375
describe('resolveHiddenConfig', () => {

packages/app/src/cli/models/project/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async function discoverDotEnvFiles(directory: string): Promise<Map<string, DotEn
223223
const paths = await glob(pattern, {dot: true})
224224
const validPaths = paths.filter((filePath) => {
225225
const fileName = basename(filePath)
226-
return fileName === '.env' || /^\.env\.\w+$/.test(fileName)
226+
return fileName === '.env' || /^\.env\.[\w-]+$/.test(fileName)
227227
})
228228

229229
const entries = await Promise.all(

0 commit comments

Comments
 (0)