8000 Merge pull request #99 from symfony-cli/docker-book-fix · symfony-cli/symfony-cli@8230e07 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8230e07

Browse files
authored
Merge pull request #99 from symfony-cli/docker-book-fix
Docker book fix
2 parents 0c2e187 + 440aae2 commit 8230e07

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

book/checkout.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,14 @@ func (b *Book) Checkout(step string) error {
101101
terminal.Println("<info>[ OK ]</>")
102102
}
103103

104+
_, err = os.Stat(filepath.Join(b.Dir, "docker-compose.yaml"))
105+
hasDocker := err == nil
106+
if !hasDocker {
107 8000 +
_, err = os.Stat(filepath.Join(b.Dir, "docker-compose.yml"))
108+
hasDocker = err == nil
109+
}
104110
printBanner("<comment>[WEB]</> Stopping Docker Containers", b.Debug)
105-
if _, err := os.Stat(filepath.Join(b.Dir, "docker-compose.yaml")); err == nil {
111+
if hasDocker {
106112
if err := executeCommand([]string{"docker-compose", "down", "--remove-orphans"}, b.Debug, false, nil); err != nil {
107113
return err
108114
}
@@ -145,7 +151,7 @@ func (b *Book) Checkout(step string) error {
145151
}
146152

147153
printBanner("<comment>[WEB]</> Starting Docker Compose", b.Debug)
148-
if _, err := os.Stat(filepath.Join(b.Dir, "docker-compose.yaml")); err == nil {
154+
if hasDocker {
149155
if err := executeCommand([]string{"docker-compose", "up", "-d"}, b.Debug, false, nil); err != nil {
150156
return err
151157
}
@@ -165,18 +171,18 @@ func (b *Book) Checkout(step string) error {
165171
}
166172

167173
printBanner("<comment>[WEB]</> Migrating the database 8000 ", b.Debug)
168-
if _, err := os.Stat(filepath.Join(b.Dir, "src", "Migrations")); err == nil {
174+
files, err := filepath.Glob(filepath.Join(b.Dir, "src", "Migrations", "*.php"))
175+
hasMigrations := err == nil && len(files) > 0
176+
if !hasMigrations {
177+
files, err = filepath.Glob(filepath.Join(b.Dir, "migrations", "*.php"))
178+
hasMigrations = err == nil && len(files) > 0
179+
}
180+
if hasMigrations {
169181
if err := executeCommand([]string{"symfony", "console", "doctrine:migrations:migrate", "-n"}, b.Debug, false, nil); err != nil {
170182
return err
171183
}
172184
} else {
173-
if _, err := os.Stat(filepath.Join(b.Dir, "migrations")); err == nil {
174-
if err := executeCommand([]string{"symfony", "console", "doctrine:migrations:migrate", "-n"}, b.Debug, false, nil); err != nil {
175-
return err
176-
}
177-
} else {
178-
terminal.Println("Skipped for this step")
179-
}
185+
terminal.Println("Skipped for this step")
180186
}
181187

182188
printBanner("<comment>[WEB]</> Inserting Fixtures", b.Debug)

envs/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ func (l *Local) getComposeDir() string {
493493
upDir := filepath.Dir(dir)
494494
if upDir == dir || upDir == "." {
495495
if l.Debug {
496-
fmt.Fprintln(os.Stderr, "ERROR: unable to find a docker-compose.yaml for the current directory")
496+
fmt.Fprintln(os.Stderr, "ERROR: unable to find a docker-compose.yaml or docker-compose.yml for the current directory")
497497
}
498498
return ""
499499
}

0 commit comments

Comments
 (0)
0