15
15
import * as fs from 'node:fs' ;
16
16
import * as git from './git' ;
17
17
import * as path from 'path' ;
18
- import { List , Map , Set } from 'immutable' ;
19
- import { minimatch } from 'minimatch' ; /* eslint-disable @typescript-eslint/no-explicit-any */
20
- import { Affected , TestAll , TestName , TestPath , mergeAffected } from './affected' ;
18
+ import { List , Map , Set } from 'immutable' ;
19
+ import { minimatch } from 'minimatch' ; /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ import { Affected , TestAll , TestName , TestPath , mergeAffected } from './affected' ;
21
21
22
- type RunTestsAll = {
22
+ type Args = {
23
23
root : string ;
24
24
path : string ;
25
25
} ;
26
26
27
- type RunTestsSome = {
27
+ type ArgsTestSome = {
28
28
root : string ;
29
29
path : string ;
30
30
tests : Map < TestPath , Set < TestName > > ;
@@ -36,27 +36,31 @@ export class Config {
36
36
match : List < string > ;
37
37
ignore : List < string > ;
38
38
packageFile : List < string > ;
39
- testAll : ( _ : RunTestsAll ) => void ;
40
- testSome : ( _ : RunTestsSome ) => void ;
39
+ _lint : ( _ : Args ) => void ;
40
+ _testAll : ( _ : Args ) => void ;
41
+ _testSome : ( _ : ArgsTestSome ) => void ;
41
42
42
43
constructor ( {
43
44
match,
44
45
ignore,
45
46
packageFile,
47
+ lint,
46
48
testAll,
47
49
testSome,
48
50
} : {
49
51
match ?: string [ ] ;
50
52
ignore ?: string [ ] ;
51
53
packageFile ?: string [ ] ;
52
- testAll ?: ( _ : RunTestsAll ) => void ;
53
- testSome ?: ( _ : RunTestsSome ) => void ;
54
+ lint ?: ( _ : Args ) => void ;
55
+ testAll ?: ( _ : Args ) => void ;
56
+ testSome ?: ( _ : ArgsTestSome ) => void ;
54
57
} ) {
55
58
this . match = List ( match || [ '**' ] ) ;
56
59
this . ignore = List ( ignore ) ;
57
60
this . packageFile = List ( packageFile ) ;
58
- this . testAll = testAll || ( _ => { } ) ;
59
- this . testSome = testSome || ( _ => { } ) ;
61
+ this . _lint = lint || ( _ => { } ) ;
62
+ this . _testAll = testAll || ( _ => { } ) ;
63
+ this . _testSome = testSome || ( _ => { } ) ;
60
64
}
61
65
62
66
affected = ( head : string , main : string ) : List < Affected > =>
@@ -71,17 +75,27 @@ export class Config {
71
75
. values ( )
72
76
) ;
73
77
78
+ lint = ( affected : Affected ) => {
79
+ const cwd = process . cwd ( ) ;
80
+ const root = git . root ( ) ;
81
+ const dir = path . join ( root , affected . path ) ;
82
+ console . log ( `> cd ${ dir } ` ) ;
83
+ process . chdir ( dir ) ;
84
+ this . _lint ( { root : root , path : affected . path } ) ;
85
+ process . chdir ( cwd ) ;
86
+ } ;
87
+
74
88
test = ( affected : Affected ) => {
75
89
const cwd = process . cwd ( ) ;
76
90
const root = git . root ( ) ;
77
91
const dir = path . join ( root , affected . path ) ;
78
92
console . log ( `> cd ${ dir } ` ) ;
79
93
process . chdir ( dir ) ;
80
94
if ( 'TestAll' in affected ) {
81
- this . testAll ( { root : root , path : affected . path } ) ;
95
+ this . _testAll ( { root : root , path : affected . path } ) ;
82
96
}
83
97
if ( 'TestSome' in affected ) {
84
- this . testSome ( {
98
+ this . _testSome ( {
85
99
root : root ,
86
100
path : affected . path ,
87
101
tests : affected . TestSome ,
0 commit comments