Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sed command for compatibility with MacOS #8

Merged
merged 1 commit into from
Jul 28, 2024
Merged
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
17 changes: 13 additions & 4 deletions scripts/prepare-dotenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ else

for environment in $environments
do
# Create a copy of .env.sample for each environment
cp .env.sample .env.$environment
# Create a copy of .env.sample for each environment
cp .env.sample .env.$environment

# Replace ENV= with ENV=<environment> in each file
sed -i "s/^ENV=.*$/ENV=$environment/g" .env.$environment
# Replace ENV= with ENV=<environment> in each file
# The command differs depending on the Unix-based system (Linux/BSD) or Mac, due to differences in the sed command
# - On GNU sed (default on Linux), no space is used between -i and '' (or ""): sed -i'' 's/foo/bar/g'.
# - On BSD sed (default on MacOS), a space is required between -i and '' (or ""): sed -i '' 's/foo/bar/g'.
if [ "$(uname)" = "Darwin" ]; then
# Mac OS X
sed -i '' -e "s/^ENV=.*$/ENV=$environment/g" .env.$environment
else
# Linux and others
sed -i'' -e "s/^ENV=.*$/ENV=$environment/g" .env.$environment
fi
done
fi