-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeLintCommand.php
35 lines (27 loc) · 1.14 KB
/
CodeLintCommand.php
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
<?php
namespace dam1r89\CodeQuality;
use Illuminate\Console\Command;
class CodeLintCommand extends Command
{
protected $signature = 'code:lint {--skip-eslint} {--skip-phpunit} {--skip-cs}';
protected $description = 'Lint the code';
public function handle()
{
if (!$this->option('skip-cs')) {
passthru('git diff --name-only --cached --diff-filter=ACMRTUXB | xargs php ./vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation --path-mode=intersection --config=.php_cs.dist --using-cache=no', $status);
}
if (!$this->option('skip-phpunit')) {
passthru('./vendor/bin/phpunit --stop-on-failure', $status2);
}
if (!$this->option('skip-eslint')) {
passthru("./node_modules/eslint/bin/eslint.js `git diff --name-only --cached --diff-filter=AM HEAD | grep '^resources/assets/js.*\.\(vue\|js\)\$'`", $status3);
}
$output = ($status ?? 0) || ($status2 ?? 0) || ($status3 ?? 0);
if ($output) {
$this->error('Not successful');
} else {
$this->info('Lint successful');
}
return (int) $output;
}
}