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: deployment error pop-up notification #67

Merged
merged 2 commits into from
Sep 26, 2023
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
7 changes: 6 additions & 1 deletion src/notification-messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from "vscode";
import { ENV0_WEB_URL } from "./common";
import stripAnsi from "strip-ansi";

const MORE_INFO_BUTTON = "More info";

Expand Down Expand Up @@ -38,7 +39,11 @@ export const showErrorMessage = (
errorMessage: string | undefined,
linkProps: LinkProps
) => {
const message = `Deployment has failed for environment ${linkProps.environmentName}. Error: ${errorMessage}`;
const normalizedErrorMessage = stripAnsi(errorMessage || "").replace(
/│|╷|╵/g,
""
);
const message = `Deployment has failed for environment ${linkProps.environmentName}. Error: ${normalizedErrorMessage}`;
vscode.window.showErrorMessage(message, MORE_INFO_BUTTON).then((button) => {
addLinkToEnvironment(button, linkProps);
});
Expand Down
3 changes: 2 additions & 1 deletion src/test/unit/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as jestMock from "jest-mock";
import expect from "expect";
// strip ansi mock must be imported before the tested module!!!
import "./mocks/strip-ansi";
// vscode mock must be imported before the tested module!!!
import {
contextMock,
Expand All @@ -9,7 +11,6 @@ import {
} from "./mocks/vscode";
import { AuthService } from "../../auth";
import { mockValidateCredentialsRequest } from "./mocks/http";

describe("authentication", () => {
const keyId = "keyId";
const secret = "secret";
Expand Down
2 changes: 2 additions & 0 deletions src/test/unit/mocks/strip-ansi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import mock from "mock-require";
mock("strip-ansi", (s: string) => s);