d384ccf31dca8b0a768c463087f156b7302c77c5

Author
Raphael Stolt <raphael.stolt@gmail.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

feat(composer): add `cuh` alias for updating global packages (#6048)

Closes #6048

Diff

 1diff --git a/plugins/composer/README.md b/plugins/composer/README.md
 2index 8c79c410929fa1a3fca31a907052d31a5870ea8a..ad6ed24bcdafd0c245b07da94afe0c8671935b2a 100644
 3--- a/plugins/composer/README.md
 4+++ b/plugins/composer/README.md
 5@@ -14,21 +14,22 @@ Original author: Daniel Gomes <me@danielcsgomes.com>
 6 
 7 ## Aliases
 8 
 9-| Alias  | Command                      | Description                                                                             |
10-| ------ | ---------------------------- | --------------------------------------------------------------------------------------- |
11-| `c`    | `composer`                   | Starts composer                                                                         |
12-| `ccp`  | `composer create-project`    | Create new project from an existing package                                             |
13-| `cdo`  | `composer dump-autoload -o`  | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production)  |
14-| `cdu`  | `composer dump-autoload`     | Updates the autoloader                                                                  |
15-| `cget` | `curl -s <installer> \| php` | Installs composer in the current directory                                              |
16-| `cgr`  | `composer global require`    | Allows require command to run on COMPOSER_HOME directory                                |
17-| `cgrm` | `composer global remove`     | Allows remove command to run on COMPOSER_HOME directory                                 |
18-| `cgu`  | `composer global update`     | Allows update command to run on COMPOSER_HOME directory                                 |
19-| `ci`   | `composer install`           | Resolves and installs dependencies from `composer.json`                                 |
20-| `co`   | `composer outdated`          | Shows a list of installed packages with available updates                               |
21-| `cod`  | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies |
22-| `cr`   | `composer require`           | Adds new packages to `composer.json`                                                    |
23-| `crm`  | `composer remove`            | Removes packages from `composer.json`                                                   |
24-| `cs`   | `composer show`              | Lists available packages, with optional filtering                                       |
25-| `csu`  | `composer self-update`       | Updates composer to the latest version                                                  |
26-| `cu`   | `composer update`            | Updates composer dependencies and `composer.lock` file                                  |
27+| Alias  | Command                            | Description                                                                             |
28+| ------ | ---------------------------------- | --------------------------------------------------------------------------------------- |
29+| `c`    | `composer`                         | Starts composer                                                                         |
30+| `ccp`  | `composer create-project`          | Create new project from an existing package                                             |
31+| `cdo`  | `composer dump-autoload -o`        | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production)  |
32+| `cdu`  | `composer dump-autoload`           | Updates the autoloader                                                                  |
33+| `cget` | `curl -s <installer> \| php`       | Installs composer in the current directory                                              |
34+| `cgr`  | `composer global require`          | Allows require command to run on COMPOSER_HOME directory                                |
35+| `cgrm` | `composer global remove`           | Allows remove command to run on COMPOSER_HOME directory                                 |
36+| `cgu`  | `composer global update`           | Allows update command to run on COMPOSER_HOME directory                                 |
37+| `ci`   | `composer install`                 | Resolves and installs dependencies from `composer.json`                                 |
38+| `co`   | `composer outdated`                | Shows a list of installed packages with available updates                               |
39+| `cod`  | `composer outdated --direct`       | Shows a list of installed packages with available updates which are direct dependencies |
40+| `cr`   | `composer require`                 | Adds new packages to `composer.json`                                                    |
41+| `crm`  | `composer remove`                  | Removes packages from `composer.json`                                                   |
42+| `cs`   | `composer show`                    | Lists available packages, with optional filtering                                       |
43+| `csu`  | `composer self-update`             | Updates composer to the latest version                                                  |
44+| `cu`   | `composer update`                  | Updates composer dependencies and `composer.lock` file                                  |
45+| `cuh`  | `composer update -d <config-home>` | Updates globally installed packages                                                     |
46diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
47index a3883a1f260073151e0f31dde1613bc3a6c90cb8..dd0b18e2728a868da88ae04a22e7f92f33e76d02 100644
48--- a/plugins/composer/composer.plugin.zsh
49+++ b/plugins/composer/composer.plugin.zsh
50@@ -48,6 +48,7 @@ alias crm='composer remove'
51 alias cs='composer show'
52 alias csu='composer self-update'
53 alias cu='composer update'
54+alias cuh='composer update --working-dir=$(composer config -g home)'
55 
56 
57 ## If Composer not found, try to add known directories to $PATH