File tree 1 file changed +7
-5
lines changed
packages/@sanity/cli/src/util
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -217,9 +217,11 @@ export async function applyEnvVariables(
217
217
await access ( join ( root , file ) )
218
218
return file
219
219
} ) ,
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
+ }
223
225
224
226
try {
225
227
const templateContent = await readFile ( join ( root , templatePath ) , 'utf8' )
@@ -231,13 +233,13 @@ export async function applyEnvVariables(
231
233
value : string ,
232
234
useQuotes : boolean ,
233
235
) => {
234
- const pattern = varRegex instanceof RegExp ? varRegex : new RegExp ( `${ varRegex } =.*$` , 'm ' )
236
+ const pattern = varRegex instanceof RegExp ? varRegex : new RegExp ( `${ varRegex } =.*$` , 'gm ' )
235
237
const match = content . match ( pattern )
236
238
if ( ! match ) return content
237
239
238
240
const varName = match [ 0 ] . split ( '=' ) [ 0 ]
239
241
return content . replace (
240
- new RegExp ( `${ varName } =.*$` , 'm ' ) ,
242
+ new RegExp ( `${ varName } =.*$` , 'gm ' ) ,
241
243
`${ varName } =${ useQuotes ? `"${ value } "` : value } ` ,
242
244
)
243
245
}
You can’t perform that action at this time.
0 commit comments