Skip to content

Commit

Permalink
fix: deployment error pop-up notification (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
meniRoy authored Sep 26, 2023
1 parent 5f81c9e commit cd30acb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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);

0 comments on commit cd30acb

Please sign in to comment.