Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows ANSI escape code rendering #503

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cmd/fastly/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
fsterrors "github.com/fastly/cli/pkg/errors"
"github.com/fastly/cli/pkg/sync"
"github.com/fastly/cli/pkg/text"
"github.com/fatih/color"
)

//go:embed static/config.toml
Expand All @@ -37,7 +38,7 @@ func main() {
clientFactory = app.FastlyAPIClient
httpClient = http.DefaultClient
in io.Reader = os.Stdin
out io.Writer = sync.NewWriter(os.Stdout)
out io.Writer = sync.NewWriter(color.Output)
versionerCLI = update.NewGitHub(update.GitHubOpts{
Org: "fastly",
Repo: "cli",
Expand Down Expand Up @@ -78,7 +79,7 @@ func main() {
} else {
// We've hit a scenario where our fallback static config is invalid, and
// that is very much an unexpected situation.
fsterrors.Deduce(err).Print(os.Stderr)
fsterrors.Deduce(err).Print(color.Error)
os.Exit(1)
}
}
Expand All @@ -93,7 +94,7 @@ func main() {
if err == config.ErrLegacyConfig || !file.ValidConfig(verboseOutput, out) {
err = file.UseStatic(cfg, config.FilePath)
if err != nil {
fsterrors.Deduce(err).Print(os.Stderr)
fsterrors.Deduce(err).Print(color.Error)
os.Exit(1)
}
}
Expand Down Expand Up @@ -156,11 +157,11 @@ Compatibility and versioning information for the Fastly CLI is being updated in
// unexpected we will have a record of any errors that happened along the way.
logErr := fsterrors.Log.Persist(fsterrors.LogPath, args)
if logErr != nil {
fsterrors.Deduce(logErr).Print(os.Stderr)
fsterrors.Deduce(logErr).Print(color.Error)
}

if err != nil {
fsterrors.Deduce(err).Print(os.Stderr)
fsterrors.Deduce(err).Print(color.Error)

// NOTE: if we have an error processing the command, then we should be sure
// to wait for the async file write to complete (otherwise we'll end up in
Expand Down Expand Up @@ -219,7 +220,7 @@ func afterWrite(verboseOutput bool, errLoadConfig error, out io.Writer) {
text.Info(out, config.UpdateSuccessful)
}
if errLoadConfig != nil {
errLoadConfig.(fsterrors.RemediationError).Print(os.Stderr)
errLoadConfig.(fsterrors.RemediationError).Print(color.Error)
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/fastly/static/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ rustup_constraint = ">= 1.23.0"
[viceroy]
ttl = "24h"

[[starter-kits.javascript]]
name = "Default starter for JavaScript"
description = "A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules."
path = "https://github.com/fastly/compute-starter-kit-javascript-default"

[[starter-kits.assemblyscript]]
name = "Default starter for AssemblyScript"
description = "A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules."
path = "https://github.com/fastly/compute-starter-kit-assemblyscript-default"

[[starter-kits.javascript]]
name = "Default starter for JavaScript"
description = "A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules."
path = "https://github.com/fastly/compute-starter-kit-javascript-default"

[[starter-kits.rust]]
name = "Beacon termination"
description = "Capture beacon data from the browser, divert beacon request payloads to a log endpoint, and avoid putting load on your own infrastructure."
Expand Down