1
+ #!/usr/bin/env node
2
+
1
3
import { exec , execSync } from "node:child_process"
2
4
import path from "node:path"
5
+ import { Command , Option } from "@commander-js/extra-typings"
6
+
7
+ const program = new Command ( )
8
+ . addOption ( new Option ( "-t --template <value>" , "filter to a single template" ) )
9
+ . addOption ( new Option ( "-s --spec <value>" , "filter to a single spec" ) )
10
+ . showHelpAfterError ( )
3
11
4
12
const templates = execSync (
5
13
"find ./integration-tests -mindepth 1 -maxdepth 1 -type d" ,
@@ -8,16 +16,29 @@ const templates = execSync(
8
16
. split ( "\n" )
9
17
. map ( ( it ) => it . trim ( ) )
10
18
. filter ( Boolean )
19
+
11
20
const definitions = execSync ( "find ./integration-tests-definitions -type f" )
12
21
. toString ( "utf-8" )
13
22
. split ( "\n" )
14
23
. map ( ( it ) => it . trim ( ) )
15
24
. filter ( Boolean )
16
25
26
+ const config = program . parse ( ) . opts ( )
27
+
28
+ const filteredTemplate = config . template
29
+ const filteredSpec = path . normalize ( config . spec )
30
+
31
+ console . info ( "filters" , { filteredTemplate, filteredSpec} )
17
32
Promise . all (
18
- templates . flatMap ( ( templatePath ) =>
19
- definitions . map ( ( definition ) => runSingle ( templatePath , definition ) ) ,
20
- ) ,
33
+ templates
34
+ . filter ( ( it ) => ! filteredTemplate || it . includes ( filteredTemplate ) )
35
+ . flatMap ( ( templatePath ) =>
36
+ definitions
37
+ . filter (
38
+ ( it ) => ! filteredSpec || path . normalize ( it ) . includes ( filteredSpec ) ,
39
+ )
40
+ . map ( ( definition ) => runSingle ( templatePath , definition ) ) ,
41
+ ) ,
21
42
)
22
43
. then ( ( ) => {
23
44
console . log ( "success!" )
0 commit comments