Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

feat: Custom composer options with the COMPOSER_FLAGS environment variable #865

Open
wants to merge 4 commits into
base: focal
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mkdir -p $NETLIFY_CACHE_DIR/.cargo
: ${NPM_FLAGS=""}
: ${PNPM_FLAGS=""}
: ${BUNDLER_FLAGS=""}
: ${COMPOSER_FLAGS=""}

# Feature flags are a comma-separated list.
# The following logic relies on the fact that feature flags cannot currently
Expand Down Expand Up @@ -291,6 +292,10 @@ run_npm() {
export PATH=$(npm bin):$PATH
}

run_composer() {
composer install ${COMPOSER_FLAGS:+$COMPOSER_FLAGS}
}

install_node() {
local defaultNodeVersion=$1
local featureFlags=$2
Expand Down Expand Up @@ -773,7 +778,7 @@ install_dependencies() {
if [ -f composer.json ]
then
restore_home_cache ".composer" "composer dependencies"
composer install
run_composer
fi

install_go $installGoVersion
Expand Down
35 changes: 35 additions & 0 deletions tests/php/composer.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bats

load "../helpers.sh"

load '../../node_modules/bats-support/load'
load '../../node_modules/bats-assert/load'
load '../../node_modules/bats-file/load'

setup() {
TMP_DIR=$(setup_tmp_dir)
set_fixture_as_repo 'simple-php' "$TMP_DIR"

# Load functions
load '../../run-build-functions.sh'
}

teardown() {
rm -rf "$TMP_DIR"
# Return to original dir
cd - || return
}

@test 'composer install' {
run run_composer
assert_success
assert_output --partial "(including require-dev)"
}

@test 'composer install with flags' {
COMPOSER_FLAGS="--no-dev"

run run_composer
assert_success
refute_output --partial "(including require-dev)"
}
4 changes: 4 additions & 0 deletions tests/php/fixtures/simple-php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "fixture/simple-php",
"require": {}
}