Skip to content

Commit

Permalink
Added support for composer v2.2.0+.
Browse files Browse the repository at this point in the history
The problem is that composer v2.2.0+ changed the way that vendor bin scripts are executed.
Now they are executed by an intermediary shell script in a way that causes their PWD to
change to the project's bin-dir, breaking project root detection.

See composer/composer#10389
  • Loading branch information
hopeseekr committed Dec 25, 2021
1 parent 2008bd6 commit 4e41a2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## v7.1.2
* **[2021-12-24 23:27:47 CDT]** Added support for composer v2.2.0+.

## v7.1.1
* **[2021-12-24 15:36:38 CDT]** Fixed the ability of selecting the PHP version via the .env file.
* **[2021-12-24 16:09:02 CDT]** Upgraded to PHP v7.4.27, 8.0.14, and 8.1.1.
Expand Down
9 changes: 8 additions & 1 deletion bin/composer
@@ -1,6 +1,13 @@
#!/usr/bin/env bash

ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
# @see https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/
# @see https://github.com/composer/composer/issues/10389
SUB="/vendor/"
if [[ "$0" == *"$SUB"* ]]; then
ROOT="$(readlink -f /proc/$PPID/cwd)"
else
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
fi

# Detect if it's running inside of docker and run it natively if it is.
# @see https://stackoverflow.com/a/25518345/430062
Expand Down
9 changes: 8 additions & 1 deletion bin/php
@@ -1,6 +1,13 @@
#!/bin/bash

ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
# @see https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/
# @see https://github.com/composer/composer/issues/10389
SUB="/vendor/"
if [[ "$0" == *"$SUB"* ]]; then
ROOT="$(readlink -f /proc/$PPID/cwd)"
else
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
fi

# Detect if it's running inside of docker and run it natively if it is.
# @see https://stackoverflow.com/a/25518345/430062
Expand Down

0 comments on commit 4e41a2b

Please sign in to comment.