From d3daa585aa5f227e5b3498069919b2277779a611 Mon Sep 17 00:00:00 2001 From: Natrim Date: Wed, 6 Aug 2014 13:46:15 +0200 Subject: [PATCH] Composer plugin - add function "composer" - uses local composer if available - add function "composer_install" to install composer to current dir --- plugins/composer/composer.fish | 10 ++++++++++ plugins/composer/composer.load | 16 ++++++++++++++++ plugins/composer/composer_install.fish | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 plugins/composer/composer.fish create mode 100644 plugins/composer/composer.load create mode 100644 plugins/composer/composer_install.fish diff --git a/plugins/composer/composer.fish b/plugins/composer/composer.fish new file mode 100644 index 0000000..192984c --- /dev/null +++ b/plugins/composer/composer.fish @@ -0,0 +1,10 @@ +# composer command +function composer + if test -e ./composer.phar # if there is composer in this path use local one + ./composer.phar $argv; + else if test -n "$COMPOSER_BIN" + eval "$COMPOSER_BIN" $argv; + else + echo "Please install composer.phar to your PATH. Or use \"composer_install\" to install Composer to current directory." + end +end diff --git a/plugins/composer/composer.load b/plugins/composer/composer.load new file mode 100644 index 0000000..fd03cdb --- /dev/null +++ b/plugins/composer/composer.load @@ -0,0 +1,16 @@ +# add Composer's global binaries to PATH +if test -z "$COMPOSER_BIN_PATH" + set -gx COMPOSER_BIN_PATH $HOME/.composer/vendor/bin +end +set PATH $COMPOSER_BIN_PATH $PATH + +# get composer path +if test -z "$COMPOSER_BIN" + if type "composer.phar" > /dev/null + set -gx COMPOSER_BIN (which composer.phar) + else if type "composer" > /dev/null + set -gx COMPOSER_BIN (which composer) + else + echo "FAILED to find Composer! Please install composer.phar to your PATH." + end +end diff --git a/plugins/composer/composer_install.fish b/plugins/composer/composer_install.fish new file mode 100644 index 0000000..5fe3499 --- /dev/null +++ b/plugins/composer/composer_install.fish @@ -0,0 +1,4 @@ +# install composer in the current directory +function composer_install + curl -s https://getcomposer.org/installer | php +end