File tree 4 files changed +37
-2
lines changed
4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 1
- import { parseCLI } from '../utils' ;
1
+ import { parseCLI , checkIfLanguageExists } from '../utils' ;
2
2
3
3
import { generateTests } from './generate' ;
4
4
5
5
async function main ( ) : Promise < void > {
6
6
const { lang, client } = parseCLI ( process . argv , 'generate:client' ) ;
7
+
8
+ if ( ! checkIfLanguageExists ( lang ) ) {
9
+ // eslint-disable-next-line no-console
10
+ console . log (
11
+ `Skipping CTS generation > generate:client for ${ lang } -${ client } : Language not present in the config.json file`
12
+ ) ;
13
+
14
+ return ;
15
+ }
16
+
7
17
// eslint-disable-next-line no-console
8
18
console . log ( `Generating CTS > generate:client for ${ lang } -${ client } ` ) ;
9
19
Original file line number Diff line number Diff line change 1
- import { parseCLI } from '../../utils' ;
1
+ import { parseCLI , checkIfLanguageExists } from '../../utils' ;
2
2
3
3
import { generateTests } from './generate' ;
4
4
5
5
async function main ( ) : Promise < void > {
6
6
const { lang, client } = parseCLI ( process . argv , 'generate:methods:requests' ) ;
7
+
8
+ if ( ! checkIfLanguageExists ( lang ) ) {
9
+ // eslint-disable-next-line no-console
10
+ console . log (
11
+ `Skipping CTS generation > generate:methods:requests for ${ lang } -${ client } : Language not present in the config.json file`
12
+ ) ;
13
+
14
+ return ;
15
+ }
16
+
7
17
// eslint-disable-next-line no-console
8
18
console . log (
9
19
`Generating CTS > generate:methods:requests for ${ lang } -${ client } `
Original file line number Diff line number Diff line change 1
1
import {
2
2
capitalize ,
3
+ checkIfLanguageExists ,
3
4
createClientName ,
4
5
removeEnumType ,
5
6
removeObjectName ,
@@ -103,4 +104,14 @@ describe('utils', () => {
103
104
} ) ;
104
105
} ) ;
105
106
} ) ;
107
+
108
+ describe ( 'checkIfLanguageExists' , ( ) => {
109
+ it ( 'returns `true` if the language is present in the config' , ( ) => {
110
+ expect ( checkIfLanguageExists ( 'javascript' ) ) . toBe ( true ) ;
111
+ } ) ;
112
+
113
+ it ( 'returns `false` if the language is not present in the config' , ( ) => {
114
+ expect ( checkIfLanguageExists ( 'algo' ) ) . toBe ( false ) ;
115
+ } ) ;
116
+ } ) ;
106
117
} ) ;
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ export function removeObjectName(obj: any): any {
76
76
return obj ;
77
77
}
78
78
79
+ export function checkIfLanguageExists ( language : string ) : boolean {
80
+ return Boolean ( ctsConfig [ language ] ) ;
81
+ }
82
+
79
83
export function removeEnumType ( obj : any ) : any {
80
84
if ( typeof obj === 'object' ) {
81
85
if ( Array . isArray ( obj ) ) {
You can’t perform that action at this time.
0 commit comments