Skip to content

Commit

Permalink
Install by composer (#9)
Browse files Browse the repository at this point in the history
* add bin section to composer.json
fix git-profile autoloader paths

* fix readme
  • Loading branch information
Rpsl authored and ziishaned committed Mar 13, 2017
1 parent 9f90070 commit 57258d8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 8 additions & 4 deletions bin/git-profile
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -21,7 +25,7 @@ if(!file_exists($autoloader)) {
fclose($stderr);
exit(1);
} else {
require_once $autoloader;
require_once $autoloader;
}

use Zeeshan\GitProfile\GitProfile;
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"psr-4": {
"Tests\\": "tests"
}
}
},
"bin": [
"bin/git-profile"
]
}

0 comments on commit 57258d8

Please sign in to comment.