forked from tinovyatkin/action-php-codesniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-on-files.ts
35 lines (31 loc) · 1.01 KB
/
run-on-files.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { execSync } from 'child_process';
import * as core from '@actions/core';
/**
* Executes phpcs on whole files and let's errors to be picked by problem matcher
* @param files
*/
export function runOnCompleteFiles(files: string[]): number {
const phpcs = core.getInput('phpcs_path', { required: true });
const args = ['--report=checkstyle'];
const standard = core.getInput('standard');
if (standard) args.push(`--standard=${standard}`);
const failOnError = core.getInput('fail_on_errors');
if (failOnError == 'false' || failOnError === 'off') {
args.push('--runtime-set ignore_errors_on_exit 1');
}
const failOnWarning = core.getInput('fail_on_warnings');
if (failOnWarning == 'false' || failOnWarning === 'off') {
args.push('--runtime-set ignore_warnings_on_exit 1');
}
try {
execSync(`${phpcs} ${args.join(' ')} ${files.join(' ')}`, {
stdio: 'inherit',
timeout: 20000,
});
return 0;
} catch (err) {
core.debug(err);
// core.setFailed(err);
return 1;
}
}