11#!/usr/bin/env node
22
3- const yargs = require ( "yargs/yargs" ) ;
4- const { hideBin } = require ( "yargs/helpers" ) ;
5- const argv = yargs ( hideBin ( process . argv ) ) . argv ;
63const { filterCyTests } = require ( "./lib/helpers/utils" ) ;
74const { fetchCyEnhancedReport } = require ( "./lib/helpers/utils/cypress" ) ;
85
96const ltClient = require ( "@lambdatest/node-rest-client" ) ;
107
11- const fetchSession = async ( options ) => {
8+ const fetchSession = async ( argv ) => {
129 // read credentials from env
1310
1411 if ( ! process . env . LT_ACCESS_KEY || ! process . env . LT_USERNAME ) {
@@ -27,19 +24,17 @@ const fetchSession = async (options) => {
2724 accessKey : process . env . LT_ACCESS_KEY ,
2825 } ) ;
2926
30- if ( ! options ) {
31- // using default options
32- options = {
27+ // using default options
28+ let options = {
3329 buildLimt : 20 ,
3430 buildName : process . env . LT_BUILD_NAME ,
3531 sessionParams : {
3632 limit : 10000 ,
3733 } ,
3834 } ;
39- }
4035
41- // fetch enhanced cy tests data
42- const fetchEnhancedCyReport = argv && argv . enhancedCyReport ;
36+ // fetch enhanced cypress tests data
37+ const fetchEnhancedCyReport = argv && argv . cypress ;
4338
4439 const data = await autoClient . getSessionsOfBuild ( options ) ;
4540
@@ -63,5 +58,14 @@ const fetchSession = async (options) => {
6358 return ;
6459} ;
6560
66- fetchSession ( ) ;
67- module . exports = fetchSession ;
61+ const argv = require ( "yargs" )
62+ . usage ( "Usage: $0 <command> [options]" )
63+ . command ( "run" , "Fetches LambdaTest automation session details" , { } , function ( argv ) {
64+ fetchSession ( argv ) ;
65+ } )
66+ . option ( 'cypress' , {
67+ alias : 'cy' ,
68+ description : 'Filter cypress test session details'
69+ } )
70+ . parse ( ) ;
71+
0 commit comments