build.php 906 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env php
  2. <?php
  3. chdir(dirname(__FILE__));
  4. $autoload = (int)$argv[1];
  5. $returnStatus = null;
  6. if (!$autoload) {
  7. // Modify composer to not autoload Stripe
  8. $composer = json_decode(file_get_contents('composer.json'), true);
  9. unset($composer['autoload']);
  10. unset($composer['require-dev']['squizlabs/php_codesniffer']);
  11. file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
  12. }
  13. passthru('composer install', $returnStatus);
  14. if ($returnStatus !== 0) {
  15. exit(1);
  16. }
  17. if ($autoload) {
  18. // Only run CS on 1 of the 2 environments
  19. passthru(
  20. './vendor/bin/phpcs --standard=PSR2 -n lib tests *.php',
  21. $returnStatus
  22. );
  23. if ($returnStatus !== 0) {
  24. exit(1);
  25. }
  26. }
  27. $config = $autoload ? 'phpunit.xml' : 'phpunit.no_autoload.xml';
  28. passthru("./vendor/bin/phpunit -c $config", $returnStatus);
  29. if ($returnStatus !== 0) {
  30. exit(1);
  31. }