mirror of
https://github.com/beego/bee.git
synced 2024-11-22 15:10:54 +00:00
getting output from shell
This commit is contained in:
parent
6f3d2d31ef
commit
5900befa43
24
migrate.go
24
migrate.go
@ -197,12 +197,12 @@ func writeMigrationSourceFile(filename string, driver string, connStr string, la
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildMigrationBinary(filename string) {
|
func buildMigrationBinary(filename string) {
|
||||||
cmd := exec.Command("go", "build", "-o", filename, filename+".go")
|
os.Chdir(path.Join("database", "migrations"))
|
||||||
|
cmd := exec.Command("go", "build", "-o", filename)
|
||||||
if out, err := cmd.CombinedOutput(); err != nil {
|
if out, err := cmd.CombinedOutput(); err != nil {
|
||||||
ColorLog("[ERRO] Could not build migration binary: %s\n", err)
|
ColorLog("[ERRO] Could not build migration binary: %s\n", err)
|
||||||
|
formatShellErrOutput(string(out))
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
} else {
|
|
||||||
ColorLog("[INFO] %s\n", string(out))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ func runMigrationBinary(filename string) {
|
|||||||
ColorLog("[ERRO] Could not run migration binary\n")
|
ColorLog("[ERRO] Could not run migration binary\n")
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
} else {
|
} else {
|
||||||
ColorLog("[INFO] %s\n", string(out))
|
formatShellOutput(string(out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +256,22 @@ func migrate(goal, driver, connStr string) {
|
|||||||
removeMigrationBinary(filepath)
|
removeMigrationBinary(filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatShellErrOutput(o string) {
|
||||||
|
for _, line := range strings.Split(o, "\n") {
|
||||||
|
if line != "" {
|
||||||
|
ColorLog("[ERRO] -| %s\n", line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func formatShellOutput(o string) {
|
||||||
|
for _, line := range strings.Split(o, "\n") {
|
||||||
|
if line != "" {
|
||||||
|
ColorLog("[INFO] -| %s\n", line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MIGRATION_MAIN_TPL = `package main
|
MIGRATION_MAIN_TPL = `package main
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user