-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathcomposer_paths.sh
executable file
·61 lines (49 loc) · 1.94 KB
/
composer_paths.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
composer_path="${1:-$(which composer)}"
working_directory="${2:-.}"
php_path="${3:-$(which php)}"
function test_composer {
"${php_path}" "${composer_path}" --version > /dev/null 2>&1
}
function validate_composer {
"${php_path}" "${composer_path}" validate --no-check-publish --no-check-lock --working-dir "${working_directory}" > /dev/null 2>&1
}
if ! test_composer; then
echo "::error title=Composer Not Found::Unable to find Composer at '${composer_path}'"
exit 1
fi
composer_json="composer.json"
composer_lock="composer.lock"
if [ -n "${working_directory}" ]; then
if [ ! -d "${working_directory}" ]; then
echo "::error title=Working Directory Not Found::Unable to find working directory at '${working_directory}'"
exit 1
fi
composer_json="${working_directory}/composer.json"
composer_lock="${working_directory}/composer.lock"
fi
if [ ! -f "${composer_json}" ]; then
echo "::error title=composer.json Not Found::Unable to find composer.json at '${composer_json}'"
exit 1
fi
if ! validate_composer; then
echo "::error title=Invalid composer.json::The composer.json file at '${composer_json}' does not validate; run 'composer validate' to check for errors"
exit 1
fi
if [ ! -f "${composer_lock}" ]; then
echo "::debug::Unable to find composer.lock at '${composer_lock}'"
composer_lock=""
fi
composer_version="$($composer_path --version)"
cache_dir="$($composer_path --working-dir="${working_directory}" config cache-dir)"
echo "::debug::Composer path is '${composer_path}'"
echo "::debug::${composer_version}"
echo "::debug::Composer cache directory found at '${cache_dir}'"
echo "::debug::File composer.json found at '${composer_json}'"
echo "::debug::File composer.lock path computed as '${composer_lock}'"
{
echo "composer_command=${composer_path}"
echo "cache-dir=${cache_dir}"
echo "json=${composer_json}"
echo "lock=${composer_lock}"
} >> "${GITHUB_OUTPUT}"