diff --git a/package.json b/package.json index 6e10fd7..f481dcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lambdatest/smartui-cli", - "version": "4.1.44", + "version": "4.1.45", "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest", "files": [ "dist/**/*" diff --git a/src/lib/server.ts b/src/lib/server.ts index e15bef1..95cb11f 100644 --- a/src/lib/server.ts +++ b/src/lib/server.ts @@ -345,6 +345,35 @@ export default async (ctx: Context): Promise { + let replyCode: number; + let replyBody: Record; + + try { + if (ctx.build && ctx.build.id) { + const buildInfo = ctx.build; + const data = { + buildId: buildInfo.id, + buildName: buildInfo.name, + baseline: buildInfo.baseline, + projectToken: ctx.env.PROJECT_TOKEN || '', + } + replyCode = 200; + replyBody = { data: data }; + } else { + throw new Error('Build information is not available'); + } + } catch (error: any) { + ctx.log.debug(`build info failed; ${error}`); + replyCode = 500; + replyBody = { error: { message: error.message } }; + } + + return reply.code(replyCode).send(replyBody); + + }); + // Use the helper function to find and start server on available port if (ctx.sourceCommand && ctx.sourceCommand === 'exec-start') {