Skip to content

Commit

Permalink
Support installing LeProxy as dependency via Composer
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Jan 26, 2022
1 parent 0be08d9 commit d08981d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ jobs:
- run: vendor/bin/phpunit --coverage-text
- run: php compile.php
- run: tests/acceptance.sh
- run: composer --working-dir=tests/install-as-dep install
- run: tests/acceptance.sh tests/install-as-dep/vendor/bin/leproxy.php
2 changes: 1 addition & 1 deletion compile.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class_exists($class, true);
}

$file = 'leproxy.php';
system('(echo "# ' . $file . '"; egrep -v "^<\?php|^require " ' . escapeshellarg($file) . ') | sed -e "s/development/release/;/define(\'VERSION\'/c const VERSION=\"' . $version . '\";" >> ' . escapeshellarg($out));
system('(echo "# ' . $file . '"; egrep -v "^<\?php|^\(@include " ' . escapeshellarg($file) . ') | sed -e "s/development/release/;/define(\'VERSION\'/c const VERSION=\"' . $version . '\";" >> ' . escapeshellarg($out));
chmod($out, 0755);
echo ' DONE (' . filesize($out) . ' bytes)' . PHP_EOL;

Expand Down
3 changes: 2 additions & 1 deletion leproxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
// this line will be replaced with the static const in the release file.
define('VERSION', ltrim(exec('git describe --always --dirty 2>/dev/null || echo unknown'), 'v'));

require __DIR__ . '/vendor/autoload.php';
// autoload for local project development or project installed as dependency
(@include __DIR__ . '/vendor/autoload.php') || require __DIR__ . '/../../autoload.php';

// parse options from command line arguments (argv)
$tokenizer = new Tokenizer();
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<testsuites>
<testsuite>
<directory>./tests/</directory>
<exclude>./tests/install-as-dep/</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
2 changes: 2 additions & 0 deletions tests/install-as-dep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/composer.lock
/vendor/
14 changes: 14 additions & 0 deletions tests/install-as-dep/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"require": {
"leproxy/leproxy": "*@dev"
},
"repositories": [
{
"type": "path",
"url": "../../",
"options": {
"symlink": false
}
}
]
}

0 comments on commit d08981d

Please sign in to comment.