@@ -6,6 +6,7 @@ import { Config } from './config.js';
6
6
import { Job } from './job.js' ;
7
7
import create_additional_jobs from './additional-checks.js' ;
8
8
import validateAndNormalizeChecks from './validate-and-normalize-checks-from-config.js' ;
9
+ import parseJsonFile from "./json.js" ;
9
10
10
11
/**
11
12
* @param {String } filename
@@ -159,44 +160,20 @@ function checks (config) {
159
160
) ,
160
161
new Check (
161
162
config . code_checks ,
162
- [
163
- function ( ) {
164
- const composerFile = JSON . parse ( fs . readFileSync ( 'composer.json' ) ) ;
165
-
166
- return (
167
- fs . existsSync ( 'infection.json' ) ||
168
- fs . existsSync ( 'infection.json.dist' )
169
- ) && ! (
170
- // Skip executing infection, if roave/infection-static-analysis-plugin (redundant task)
171
- composerFile . hasOwnProperty ( 'require-dev' ) &&
172
- composerFile [ 'require-dev' ] . hasOwnProperty ( 'roave/infection-static-analysis-plugin' )
173
- ) ;
174
- }
175
- ] ,
163
+ [ fileTest ( 'infection.json' ) , fileTest ( 'infection.json.dist' ) ] ,
176
164
/**
177
165
* @param {Config } config
178
166
* @return {Array }
179
167
*/
180
168
function ( config ) {
181
- return createQaJobs ( './vendor/bin/infection' , config ) ;
182
- }
183
- ) ,
184
- new Check (
185
- config . code_checks ,
186
- [
187
- function ( ) {
188
- const composerFile = JSON . parse ( fs . readFileSync ( 'composer.json' ) ) ;
169
+ const composerFile = parseJsonFile ( 'composer.json' , false ) ;
170
+ let commandToExecute = 'vendor/bin/infection' ;
189
171
190
- return composerFile . hasOwnProperty ( 'require-dev' ) &&
191
- composerFile [ 'require-dev' ] . hasOwnProperty ( 'roave/ infection-static-analysis-plugin') ;
172
+ if ( composerFile . hasOwnProperty ( 'require-dev' ) && composerFile [ 'require-dev' ] . hasOwnProperty ( 'roave/infection-static-analysis-plugin' ) ) {
173
+ commandToExecute = 'vendor/bin/roave- infection-static-analysis-plugin';
192
174
}
193
- ] ,
194
- /**
195
- * @param {Config } config
196
- * @return {Array }
197
- */
198
- function ( config ) {
199
- return createQaJobs ( './vendor/bin/roave-infection-static-analysis-plugin' , config ) ;
175
+
176
+ return createQaJobs ( commandToExecute , config ) ;
200
177
}
201
178
) ,
202
179
new Check (
0 commit comments