@@ -18,9 +18,9 @@ const validBaseEnv = {
18
18
TRAVIS_PULL_REQUEST_SLUG : 'TRAVIS_PULL_REQUEST_SLUG'
19
19
} ;
20
20
21
- const cli = async ( config = { } ) => {
21
+ const cli = async ( config = { } , args = [ ] ) => {
22
22
try {
23
- return await execa ( bin , [ ] , config ) ;
23
+ return await execa ( bin , args , config ) ;
24
24
} catch ( err ) {
25
25
throw new Error ( [ err . stdout , err . stderr ] . join ( '\n' ) ) ;
26
26
}
@@ -98,6 +98,39 @@ test('should call git with expected args on pull_request', async () => {
98
98
] ) ;
99
99
} ) ;
100
100
101
+ test ( 'should call git with extra expected args on pull_request' , async ( ) => {
102
+ const cwd = await git . clone (
103
+ 'https://github.com/conventional-changelog/commitlint.git' ,
104
+ [ '--depth=10' ] ,
105
+ __dirname ,
106
+ TRAVIS_COMMITLINT_GIT_BIN
107
+ ) ;
108
+
109
+ const result = await cli (
110
+ {
111
+ cwd,
112
+ env : { ...validBaseEnv , TRAVIS_EVENT_TYPE : 'pull_request' }
113
+ } ,
114
+ [ '--config' , './config/commitlint.config.js' ]
115
+ ) ;
116
+ const invocations = await getInvocations ( result . stdout ) ;
117
+ expect ( invocations . length ) . toBe ( 3 ) ;
118
+
119
+ const [ stash , branches , commilint ] = invocations ;
120
+
121
+ expect ( stash ) . toEqual ( [ 'git' , 'stash' , '-k' , '-u' , '--quiet' ] ) ;
122
+ expect ( branches ) . toEqual ( [ 'git' , 'stash' , 'pop' , '--quiet' ] ) ;
123
+ expect ( commilint ) . toEqual ( [
124
+ 'commitlint' ,
125
+ '--from' ,
126
+ 'TRAVIS_COMMIT_A' ,
127
+ '--to' ,
128
+ 'TRAVIS_COMMIT_B' ,
129
+ '--config' ,
130
+ './config/commitlint.config.js'
131
+ ] ) ;
132
+ } ) ;
133
+
101
134
function getInvocations ( stdout ) {
102
135
const matches = stdout . match ( / [ ^ [ \] ] + / g) ;
103
136
const raw = Array . isArray ( matches ) ? matches : [ ] ;
0 commit comments