Skip to content

Commit 47abf94

Browse files
fix: remove empty string from sed args when not on Darwin (#2100)
1 parent f3a09fa commit 47abf94

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.changeset/fast-hounds-invent.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-t3-app": patch
3+
---
4+
5+
Fix database start scripts to work better on linux

cli/template/extras/start-database/mysql.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ source .env
1717
DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}')
1818
DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}')
1919
DB_NAME=$(echo "$DATABASE_URL" | awk -F'/' '{print $4}')
20-
DB_CONTAINER_NAME="$DB_NAME-postgres"
20+
DB_CONTAINER_NAME="$DB_NAME-mysql"
2121

2222
if ! [ -x "$(command -v docker)" ] && ! [ -x "$(command -v podman)" ]; then
2323
echo -e "Docker or Podman is not installed. Please install docker or podman and try again.\nDocker install guide: https://docs.docker.com/engine/install/\nPodman install guide: https://podman.io/getting-started/installation"
@@ -70,7 +70,12 @@ if [ "$DB_PASSWORD" == "password" ]; then
7070
fi
7171
# Generate a random URL-safe password
7272
DB_PASSWORD=$(openssl rand -base64 12 | tr '+/' '-_')
73-
sed -i '' "s#:password@#:$DB_PASSWORD@#" .env
73+
if [[ "$(uname)" == "Darwin" ]]; then
74+
# macOS requires an empty string to be passed with the `i` flag
75+
sed -i '' "s#:password@#:$DB_PASSWORD@#" .env
76+
else
77+
sed -i "s#:password@#:$DB_PASSWORD@#" .env
78+
fi
7479
fi
7580

7681
$DOCKER_CMD run -d \

cli/template/extras/start-database/postgres.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ if [ "$DB_PASSWORD" = "password" ]; then
7171
fi
7272
# Generate a random URL-safe password
7373
DB_PASSWORD=$(openssl rand -base64 12 | tr '+/' '-_')
74-
sed -i '' "s#:password@#:$DB_PASSWORD@#" .env
74+
if [[ "$(uname)" == "Darwin" ]]; then
75+
# macOS requires an empty string to be passed with the `i` flag
76+
sed -i '' "s#:password@#:$DB_PASSWORD@#" .env
77+
else
78+
sed -i "s#:password@#:$DB_PASSWORD@#" .env
79+
fi
7580
fi
7681

7782
$DOCKER_CMD run -d \

0 commit comments

Comments
 (0)