diff options
| author | Ryan Tvenge <ryan@hoverboardstudios.com> | 2023-10-19 09:41:36 -0500 | 
|---|---|---|
| committer | Marc Cornellà <marc@mcornella.com> | 2023-10-19 20:38:37 +0200 | 
| commit | a8dee63ffe8839d3bcf1066f8359fa43caccf3f2 (patch) | |
| tree | 89b4e89741718ca677755683b611c7497075f01a | |
| parent | 104041a018dc9a3eb74f93815192dba4c9386e1a (diff) | |
| download | zsh-a8dee63ffe8839d3bcf1066f8359fa43caccf3f2.tar.gz zsh-a8dee63ffe8839d3bcf1066f8359fa43caccf3f2.tar.bz2 zsh-a8dee63ffe8839d3bcf1066f8359fa43caccf3f2.zip  | |
feat(lando): bypass `lando` if command is not available in container (#11993)
Closes #11993
| -rw-r--r-- | plugins/lando/lando.plugin.zsh | 16 | 
1 files changed, 12 insertions, 4 deletions
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh index af53e7e5a..b5fa80092 100644 --- a/plugins/lando/lando.plugin.zsh +++ b/plugins/lando/lando.plugin.zsh @@ -11,15 +11,23 @@ function artisan \           php \           wp \           yarn { -  if checkForLandoFile; then -    lando "$0" "$@" +  # If the lando task is available in `lando --help`, then it means: +  # +  # 1. `lando` is in a project with a `.lando.yml` file. +  # 2. The lando task is available for lando, based on the .lando.yml config file. +  # +  # This has a penalty of about 250ms, so we still want to check if the lando file +  # exists before, which is the fast path. If it exists, checking help output is +  # still faster than running the command and failing. +  if _lando_file_exists && lando --help 2>&1 | command grep -Eq "^ +lando $0 "; then +    command lando "$0" "$@"    else      command "$0" "$@"    fi  }  # Check for the file in the current and parent directories. -checkForLandoFile() { +_lando_file_exists() {    # Only bother checking for lando within the Sites directory.    if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then      # Not within $LANDO_ZSH_SITES_DIRECTORY @@ -38,4 +46,4 @@ checkForLandoFile() {    # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory    # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.    return 1 -}
\ No newline at end of file +}  | 
