Skip to content
Snippets Groups Projects
Commit 4288f330 authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Added logs

parent 46529904
Branches
Tags
No related merge requests found
...@@ -3,13 +3,11 @@ package mage_helpers ...@@ -3,13 +3,11 @@ package mage_helpers
import ( import (
_ "embed" _ "embed"
"fmt" "fmt"
"gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strconv" "strconv"
"strings"
"gopkg.in/yaml.v2"
) )
func CDKCompileTypeScript(cdkDir string) error { func CDKCompileTypeScript(cdkDir string) error {
...@@ -50,8 +48,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool, profile string ...@@ -50,8 +48,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool, profile string
`--exclusively=true`, `--exclusively=true`,
`--progress=events`) `--progress=events`)
fmt.Println(fmt.Sprintf("Running command: cdk %s", strings.Join(commandArgs, " "))) cmd := BuildCommand("cdk", commandArgs)
cmd := exec.Command("cdk", commandArgs...)
cmd.Dir = cdkDir cmd.Dir = cdkDir
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
...@@ -90,9 +87,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local ...@@ -90,9 +87,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local
`--progress=events`, `--progress=events`,
`--app=./cdk.out`) `--app=./cdk.out`)
fmt.Println(fmt.Sprintf("Running command: cdk %s", strings.Join(commandArgs, " "))) cmd := BuildCommand("cdk", commandArgs)
cmd := exec.Command("cdk", commandArgs...)
cmd.Dir = cdkDir cmd.Dir = cdkDir
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
...@@ -123,8 +118,7 @@ func CDKSynthAll(cdkDir string, env string, profile string, local bool) error { ...@@ -123,8 +118,7 @@ func CDKSynthAll(cdkDir string, env string, profile string, local bool) error {
commandArgs = append(commandArgs, commandArgs = append(commandArgs,
`--progress=events`) `--progress=events`)
fmt.Println(fmt.Sprintf("Running command: cdk %s", strings.Join(commandArgs, " "))) cmd := BuildCommand("cdk", commandArgs)
cmd := exec.Command("cdk", commandArgs...)
cmd.Dir = cdkDir cmd.Dir = cdkDir
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
...@@ -176,9 +170,7 @@ func CDKSynthDebug(cdkDir string, env string, handler string, appName string, pr ...@@ -176,9 +170,7 @@ func CDKSynthDebug(cdkDir string, env string, handler string, appName string, pr
`--no-staging`, `--no-staging`,
} }
fmt.Println(fmt.Sprintf("Running command: cdk %s", strings.Join(commandArgs, " "))) cmd := BuildCommand("cdk", commandArgs)
cmd := exec.Command("cdk", commandArgs...)
cmd.Dir = cdkDir cmd.Dir = cdkDir
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
......
...@@ -86,6 +86,7 @@ func runLongRunningSubProcess(ctx context.Context, name string, arg ...string) e ...@@ -86,6 +86,7 @@ func runLongRunningSubProcess(ctx context.Context, name string, arg ...string) e
cancel() cancel()
}() }()
fmt.Println(fmt.Sprintf("Running command: %s %s", name, strings.Join(arg, " ")))
cmd := exec.CommandContext(cancelContext, name, arg...) cmd := exec.CommandContext(cancelContext, name, arg...)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
......
...@@ -2,13 +2,16 @@ package mage_helpers ...@@ -2,13 +2,16 @@ package mage_helpers
import ( import (
"context" "context"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"os/exec"
"os/signal" "os/signal"
"path" "path"
"path/filepath" "path/filepath"
"strings"
"github.com/thoas/go-funk" "github.com/thoas/go-funk"
...@@ -168,3 +171,9 @@ func killWithContext(ctx context.Context) { ...@@ -168,3 +171,9 @@ func killWithContext(ctx context.Context) {
os.Exit(exitCodeInterrupt) os.Exit(exitCodeInterrupt)
}() }()
} }
func BuildCommand(command string, args []string) *exec.Cmd {
fmt.Println(fmt.Sprintf("Running command: %s %s", command, strings.Join(args, " ")))
cmd := exec.Command(command, args...)
return cmd
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment