-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
composer_install.sh
executable file
·33 lines (26 loc) · 1017 Bytes
/
composer_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
dependency_versions="${1:-locked}"
additional_composer_options="${2}"
working_directory="${3}"
php_path="${4:-$(which php)}"
composer_path="${5:-$(which composer)}"
composer_lock="${6}"
composer_command="update"
composer_options=("--no-interaction" "--no-progress" "--ansi")
case "${dependency_versions}" in
highest) composer_command="update" ;;
lowest) composer_options+=("--prefer-lowest" "--prefer-stable") ;;
*) composer_command="install" ;;
esac
# If there is no composer.lock file, then use the `update` command.
if [ -z "${composer_lock}" ]; then
composer_command="update"
fi
read -r -a additional_options <<<"${additional_composer_options}"
composer_options+=("${additional_options[@]}")
if [ -n "${working_directory}" ]; then
composer_options+=("--working-dir" "${working_directory}")
fi
full_command="${php_path} ${composer_path} ${composer_command} ${composer_options[*]}"
echo "::debug::Using the following Composer command: '${full_command}'"
$full_command