Skip to content

Commit

Permalink
fix(cli): correctly clean on compas docker clean --project foo-bar
Browse files Browse the repository at this point in the history
…with a `-` in the name
  • Loading branch information
dirkdev98 committed Sep 15, 2023
1 parent a6f65e7 commit 6cf9cca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/compas/commands/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,16 @@ async function cleanContainers(logger, state, context) {
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid();";
for (const command of stdout.split("\n")) {
if (command.trim().startsWith("DROP DATABASE")) {
pgCommand += `${command.trim()};`;
pgCommand += `${command.trim()}`;
}
}

for (const project of projects) {
pgCommand += `CREATE DATABASE ${project};`;
pgCommand += `CREATE DATABASE "${project}";`;
}

const { exitCode, ...dockerLogs } = await exec(
`echo "${pgCommand}" | docker exec -i ${postgresContainer} psql --user postgres`,
`echo '${pgCommand}' | docker exec -i ${postgresContainer} psql --user postgres`,
);

if (exitCode !== 0) {
Expand Down

0 comments on commit 6cf9cca

Please sign in to comment.