Skip to content

Commit 8f6d8b4

Browse files
authored
Merge pull request #416 from shreyansh-chandel/creds-support-in-exec-command
Added support for passing LT creds via exec command options
2 parents 9f8793c + a732e21 commit 8f6d8b4

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/commander/exec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { color, Listr, ListrDefaultRendererLogLevels } from 'listr2'
55
import startServer from '../tasks/startServer.js'
66
import authExec from '../tasks/authExec.js'
77
import ctxInit from '../lib/ctx.js'
8+
import commandOptionsInit from '../lib/execCommandOptions.js'
89
import getGitInfo from '../tasks/getGitInfo.js'
910
import createBuildExec from '../tasks/createBuildExec.js'
1011
import exec from '../tasks/exec.js'
@@ -43,6 +44,8 @@ command
4344
ctx.totalSnapshots = 0
4445
ctx.sourceCommand = 'exec'
4546

47+
commandOptionsInit(ctx);
48+
4649
let tasks = new Listr<Context>(
4750
[
4851
authExec(ctx),

src/lib/ctx.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export default (options: Record<string, string>): Context => {
9595
if (options.userName && options.accessKey) {
9696
env.LT_USERNAME = options.userName
9797
env.LT_ACCESS_KEY = options.accessKey
98+
process.env.LT_USERNAME = options.userName
99+
process.env.LT_ACCESS_KEY = options.accessKey
98100
}
99101
} catch (error: any) {
100102
console.log(`[smartui] Error: ${error.message}`);
@@ -210,7 +212,9 @@ export default (options: Record<string, string>): Context => {
210212
baselineBranch: options.baselineBranch || '',
211213
baselineBuild: options.baselineBuild || '',
212214
githubURL : options.githubURL || '',
213-
showRenderErrors: options.showRenderErrors ? true : false
215+
showRenderErrors: options.showRenderErrors ? true : false,
216+
userName: options.userName || '',
217+
accessKey: options.accessKey || ''
214218
},
215219
cliVersion: version,
216220
totalSnapshots: -1,

src/lib/execCommandOptions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Context } from '../types.js'
2+
3+
export default (ctx: Context): Context => {
4+
if(ctx.args.execCommand && !ctx.options.userName && !ctx.options.accessKey) {
5+
for(const arg of ctx.args.execCommand) {
6+
if(arg.includes('lambdaTestUserName')) {
7+
ctx.env.LT_USERNAME = arg.split('=')[1];
8+
}
9+
if(arg.includes('lambdaTestAccessKey')) {
10+
ctx.env.LT_ACCESS_KEY = arg.split('=')[1];
11+
}
12+
}
13+
}
14+
return ctx;
15+
}

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export interface Context {
7474
baselineBranch?: string,
7575
baselineBuild?: string,
7676
githubURL?: string,
77-
showRenderErrors?: boolean
77+
showRenderErrors?: boolean,
78+
userName?: string,
79+
accessKey?: string
7880
}
7981
cliVersion: string;
8082
totalSnapshots: number;

0 commit comments

Comments
 (0)