Skip to content

Commit 41580c4

Browse files
authoredJan 13, 2025··
feat(cli): slim down remote test template (#8224)
1 parent 78318f3 commit 41580c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+65
-4744
lines changed
 

‎packages/@sanity/cli/.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# package specific
22
/templates
3-
/test/test-template

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,17 @@ export async function applyEnvVariables(
233233
value: string,
234234
useQuotes: boolean,
235235
) => {
236-
const pattern = varRegex instanceof RegExp ? varRegex : new RegExp(`${varRegex}=.*$`, 'gm')
237-
const match = content.match(pattern)
238-
if (!match) return content
239-
240-
const varName = match[0].split('=')[0]
241-
return content.replace(
242-
new RegExp(`${varName}=.*$`, 'gm'),
243-
`${varName}=${useQuotes ? `"${value}"` : value}`,
244-
)
236+
const varPattern = typeof varRegex === 'string' ? varRegex : varRegex.source
237+
const pattern = new RegExp(`.*${varPattern}=.*$`, 'gm')
238+
const matches = content.matchAll(pattern)
239+
return Array.from(matches).reduce((updatedContent, match) => {
240+
if (!match[0]) return updatedContent
241+
const varName = match[0].split('=')[0].trim()
242+
return updatedContent.replace(
243+
new RegExp(`${varName}=.*$`, 'gm'),
244+
`${varName}=${useQuotes ? `"${value}"` : value}`,
245+
)
246+
}, content)
245247
}
246248

247249
let envContent = templateContent

0 commit comments

Comments
 (0)
Please sign in to comment.