Skip to content

Commit

Permalink
refactor: rework the way on how either `roave/infection-static-analys…
Browse files Browse the repository at this point in the history
…is-plugin` or `infection/infection` is being used

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Oct 10, 2021
1 parent b49cb83 commit b9d6a6c
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions src/create-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Config } from './config.js';
import { Job } from './job.js';
import create_additional_jobs from './additional-checks.js';
import validateAndNormalizeChecks from './validate-and-normalize-checks-from-config.js';
import parseJsonFile from "./json.js";

/**
* @param {String} filename
Expand Down Expand Up @@ -159,44 +160,20 @@ function checks (config) {
),
new Check(
config.code_checks,
[
function () {
const composerFile = JSON.parse(fs.readFileSync('composer.json'));

return (
fs.existsSync('infection.json') ||
fs.existsSync('infection.json.dist')
) && ! (
// Skip executing infection, if roave/infection-static-analysis-plugin (redundant task)
composerFile.hasOwnProperty('require-dev') &&
composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin')
);
}
],
[fileTest('infection.json'), fileTest('infection.json.dist')],
/**
* @param {Config} config
* @return {Array}
*/
function (config) {
return createQaJobs('./vendor/bin/infection', config);
}
),
new Check(
config.code_checks,
[
function () {
const composerFile = JSON.parse(fs.readFileSync('composer.json'));
const composerFile = parseJsonFile('composer.json', false);
let commandToExecute = 'vendor/bin/infection';

return composerFile.hasOwnProperty('require-dev') &&
composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin');
if (composerFile.hasOwnProperty('require-dev') && composerFile['require-dev'].hasOwnProperty('roave/infection-static-analysis-plugin')) {
commandToExecute = 'vendor/bin/roave-infection-static-analysis-plugin';
}
],
/**
* @param {Config} config
* @return {Array}
*/
function (config) {
return createQaJobs('./vendor/bin/roave-infection-static-analysis-plugin', config);

return createQaJobs(commandToExecute, config);
}
),
new Check(
Expand Down

0 comments on commit b9d6a6c

Please sign in to comment.