Skip to content

Commit

Permalink
Fix execution path
Browse files Browse the repository at this point in the history
  • Loading branch information
rogervila authored Feb 19, 2019
1 parent 133b46d commit e5c07c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<p align="center"><img width="250" src="https://i.imgur.com/xcIhGwP.png" alt="Run SonarQube Scanner with composer" /></p>

[![Latest Stable Version](https://poser.pugx.org/rogervila/php-sonarqube-scanner/v/stable)](https://packagist.org/packages/rogervila/php-sonarqube-scanner)
[![Total Downloads](https://poser.pugx.org/rogervila/php-sonarqube-scanner/downloads)](https://packagist.org/packages/rogervila/php-sonarqube-scanner)
[![Build Status](https://travis-ci.org/rogervila/php-sonarqube-scanner.svg?branch=master)](https://travis-ci.org/rogervila/php-sonarqube-scanner)
[![Build status](https://ci.appveyor.com/api/projects/status/weidwo98jcdrtkxm?svg=true)](https://ci.appveyor.com/project/roger-vila/php-sonarqube-scanner)



# Run SonarQube Scanner with composer

## Usage

**Install the package as a dev requirement**

```
composer install rogervila/php-sonarqube-scanner --dev
composer require rogervila/php-sonarqube-scanner --dev
```


Expand Down
37 changes: 11 additions & 26 deletions sonar-scanner
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,12 @@ if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

$paths = [
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php',
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
];

foreach ($paths as $file) {
if (file_exists($file)) {
define('COMPOSER_AUTOLOAD_FILE', $file);
break;
}
}

$paths = [
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json',
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json',
__DIR__ . DIRECTORY_SEPARATOR . 'composer.json',
];
$file = getcwd() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

foreach ($paths as $file) {
if (file_exists($file)) {
define('COMPOSER_CONFIG_FILE', $file);
break;
}
if (file_exists($file)) {
define('COMPOSER_AUTOLOAD_FILE', $file);
}

unset($file);
unset($paths);

if (!defined('COMPOSER_AUTOLOAD_FILE')) {
fwrite(
STDERR,
Expand All @@ -45,6 +22,14 @@ if (!defined('COMPOSER_AUTOLOAD_FILE')) {
die(1);
}

$file = getcwd() . DIRECTORY_SEPARATOR . 'composer.json';

if (file_exists($file)) {
define('COMPOSER_CONFIG_FILE', $file);
}

unset($file);

require COMPOSER_AUTOLOAD_FILE;

$app = new \Sonar\Scanner();
Expand Down

0 comments on commit e5c07c5

Please sign in to comment.