Skip to content

Commit 81042da

Browse files
committed
chore: leverage regex named capture groups for deploy id and site name
1 parent aba1db7 commit 81042da

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tests/utils/create-e2e-fixture.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,16 @@ async function deploySite(
279279
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
280280
const output = await readFile(join(siteDir, outputFile), 'utf-8')
281281

282-
const [url] = new RegExp(/next-runtime-testing\/deploys\/[0-9a-f]+/gm).exec(output) || []
283-
if (!url) {
284-
throw new Error('Could not extract the URL from the build logs')
285-
}
282+
const { siteName, deployID } = new RegExp(
283+
/app\.netlify\.com\/sites\/(?<siteName>.+)\/deploys\/(?<deployID>[0-9a-f]+)/gm
284+
).exec(output)?.groups || {}
286285

287-
const deployID = url.split('/').pop()
288286
if (!deployID) {
289287
throw new Error('Could not extract DeployID from the build logs')
290288
}
291289

292290
return {
293-
url: `https://${deployID}--next-runtime-testing.netlify.app/`,
291+
url: `https://${deployID}--${siteName}.netlify.app/`,
294292
deployID,
295293
logs: output,
296294
}

0 commit comments

Comments
 (0)