From 57258d8c147bbe142ce7f379b221cb72bb1150ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=20=D0=94=D0=B8=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80?= Date: Mon, 13 Mar 2017 12:32:53 +0300 Subject: [PATCH] Install by composer (#9) * add bin section to composer.json fix git-profile autoloader paths * fix readme --- README.md | 19 +++++++++++++++++++ bin/git-profile | 12 ++++++++---- composer.json | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index be46082..76621e0 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,25 @@ This utility helps you save profiles and then you can switch between them using ## Install +``` +$ composer global require zeeshan/git-profile +``` +Then check your ```$PATH``` variable. It must contain ```~/.composer/vendor/bin``` dir. + +``` +$ echo $PATH + +/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/home/username/.composer/vendor/bin +``` + +Modify your ```.zshrc``` or ```.bashrc``` files if your ```$PATH``` variable not contain composer/bin dir. + +``` +export PATH=~/.composer/vendor/bin:$PATH +``` + +#### Also you can use .phar file + * Download the file from [here](https://github.com/zeeshanu/git-profile/releases/download/v1.0/git-profile) * `sudo chmod -R 755 git-profile` * `sudo mv git-profile /usr/local/bin/git-profile` diff --git a/bin/git-profile b/bin/git-profile index 995bf4d..712a7e3 100755 --- a/bin/git-profile +++ b/bin/git-profile @@ -8,10 +8,14 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -$autoloader = __DIR__ . '/../vendor/autoload.php'; +if (file_exists(__DIR__ . '/../vendor/autoload.php')) { + $autoloader = __DIR__ . '/../vendor/autoload.php'; +} else { + $autoloader = __DIR__ . '/../../../autoload.php'; +} -if(!file_exists($autoloader)) { - $stderr = fopen('php://stderr', 'w'); +if (!file_exists($autoloader)) { + $stderr = fopen('php://stderr', 'w'); fwrite( $stderr, 'Unable to find composer autoloader. Make sure dependencies are ' @@ -21,7 +25,7 @@ if(!file_exists($autoloader)) { fclose($stderr); exit(1); } else { - require_once $autoloader; + require_once $autoloader; } use Zeeshan\GitProfile\GitProfile; diff --git a/composer.json b/composer.json index 5bfd73b..938612a 100644 --- a/composer.json +++ b/composer.json @@ -28,5 +28,8 @@ "psr-4": { "Tests\\": "tests" } - } + }, + "bin": [ + "bin/git-profile" + ] }