Skip to content

Commit b3986d9

Browse files
committed
feat: enabled colors when driftctl is piped in snyk CLI
1 parent c9087ea commit b3986d9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/snyk/driftctl/pkg/config"
1818
"github.com/snyk/driftctl/pkg/version"
1919
"github.com/snyk/driftctl/sentry"
20+
"github.com/spf13/viper"
2021
)
2122

2223
func init() {
@@ -33,12 +34,20 @@ func run() int {
3334
config.Init()
3435
logger.Init()
3536
build := build.Build{}
37+
// Check whether driftCTL is run under Snyk CLI
38+
isSnyk := viper.GetBool("IS_SNYK")
3639
logrus.WithFields(logrus.Fields{
3740
"isRelease": fmt.Sprintf("%t", build.IsRelease()),
3841
"isUsageReportingEnabled": fmt.Sprintf("%t", build.IsUsageReportingEnabled()),
3942
"version": version.Current(),
43+
"isSnyk": fmt.Sprintf("%t", isSnyk),
4044
}).Debug("Build info")
4145

46+
// Enable colorization when driftctl is launched under snyk cli (piped)
47+
if isSnyk {
48+
color.NoColor = false
49+
}
50+
4251
driftctlCmd := cmd.NewDriftctlCmd(build)
4352

4453
checkVersion := driftctlCmd.ShouldCheckVersion()

0 commit comments

Comments
 (0)