Skip to content

Commit 86c6ab1

Browse files
authoredJan 10, 2025
feat(cli): skip directories without .env.example when bootstrapping remote template (#8216)
1 parent 5c28f4f commit 86c6ab1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎packages/@sanity/cli/src/util/remoteTemplate.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ export async function applyEnvVariables(
217217
await access(join(root, file))
218218
return file
219219
}),
220-
).catch(() => {
221-
throw new Error('Could not find .env.template, .env.example or .env.local.example file')
222-
})
220+
).catch(() => undefined)
221+
222+
if (!templatePath) {
223+
return // No template .env file found, skip
224+
}
223225

224226
try {
225227
const templateContent = await readFile(join(root, templatePath), 'utf8')
@@ -231,13 +233,13 @@ export async function applyEnvVariables(
231233
value: string,
232234
useQuotes: boolean,
233235
) => {
234-
const pattern = varRegex instanceof RegExp ? varRegex : new RegExp(`${varRegex}=.*$`, 'm')
236+
const pattern = varRegex instanceof RegExp ? varRegex : new RegExp(`${varRegex}=.*$`, 'gm')
235237
const match = content.match(pattern)
236238
if (!match) return content
237239

238240
const varName = match[0].split('=')[0]
239241
return content.replace(
240-
new RegExp(`${varName}=.*$`, 'm'),
242+
new RegExp(`${varName}=.*$`, 'gm'),
241243
`${varName}=${useQuotes ? `"${value}"` : value}`,
242244
)
243245
}

0 commit comments

Comments
 (0)