Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
Support being installed as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Apr 28, 2017
1 parent 9393669 commit 6c80fdc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sniff
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,21 @@ if ($config['allow-risky']) {
$options .= ' --allow-risky=yes';
}

$command = sprintf(
"vendor/bin/php-cs-fixer fix %s %s --using-cache=no --rules=%s",
if (file_exists('vendor/bin/php-cs-fixer')) {
// Installed in vendor sub-directory
$command = 'vendor/bin/php-cs-fixer';
} elseif (file_exists(__DIR__.'/php-cs-fixer')) {
// When sniff is installed as a dependency, along with php-cs-fixer in vendor/bin/
$command = __DIR__.'/php-cs-fixer';
} else {
// Global install
$command = 'php-cs-fixer';
}

passthru(sprintf(
"%s fix %s %s --using-cache=no --rules=%s",
$command,
$paths,
$options,
escapeshellarg(json_encode($config['rules']))
);
passthru($command);
));

0 comments on commit 6c80fdc

Please sign in to comment.