@utoo/pack-shared 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/issue.d.ts CHANGED
@@ -25,5 +25,5 @@ export interface SourcePos {
25
25
  line: number;
26
26
  column: number;
27
27
  }
28
- export declare function formatIssue(issue: Issue): string;
29
- export declare function handleIssues(issues: Issue[]): void;
28
+ export declare function formatIssue(issue: Issue, forceColor?: boolean): string;
29
+ export declare function handleIssues(issues: Issue[], forceColor?: boolean): void;
package/esm/issue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { codeFrameColumns } from "@babel/code-frame";
2
2
  import { renderStyledStringToErrorAnsi } from "./styledString";
3
- export function formatIssue(issue) {
3
+ export function formatIssue(issue, forceColor = true) {
4
4
  const { filePath, title, description, source } = issue;
5
5
  let { documentationLink } = issue;
6
6
  let formattedTitle = renderStyledStringToErrorAnsi(title).replace(/\n/g, "\n ");
@@ -32,7 +32,9 @@ export function formatIssue(issue) {
32
32
  line: end.line + 1,
33
33
  column: end.column + 1,
34
34
  },
35
- }, { forceColor: true }).trim() + "\n\n";
35
+ },
36
+ // forceColor display is noise on browser
37
+ { forceColor }).trim() + "\n\n";
36
38
  }
37
39
  if (description) {
38
40
  message += renderStyledStringToErrorAnsi(description) + "\n\n";
@@ -47,22 +49,22 @@ export function formatIssue(issue) {
47
49
  }
48
50
  return message;
49
51
  }
50
- export function handleIssues(issues) {
51
- const topLevelErrors = [];
52
- const topLevelWarnings = [];
52
+ export function handleIssues(issues, forceColor = true) {
53
+ const topLevelErrors = new Set();
54
+ const topLevelWarnings = new Set();
53
55
  for (const issue of issues) {
54
56
  if (issue.severity === "error" || issue.severity === "fatal") {
55
- topLevelErrors.push(formatIssue(issue));
57
+ topLevelErrors.add(formatIssue(issue, forceColor));
56
58
  }
57
59
  else if (isRelevantWarning(issue)) {
58
- topLevelWarnings.push(formatIssue(issue));
60
+ topLevelWarnings.add(formatIssue(issue, forceColor));
59
61
  }
60
62
  }
61
- if (topLevelWarnings.length > 0) {
62
- console.warn(`Utoopack build encountered ${topLevelWarnings.length} warnings:\n${topLevelWarnings.join("\n")}`);
63
+ if (topLevelWarnings.size !== 0) {
64
+ console.warn(`Utoopack build encountered ${topLevelWarnings.size} warnings:\n${[...topLevelWarnings].join("\n")}`);
63
65
  }
64
- if (topLevelErrors.length > 0) {
65
- throw new Error(`Utoopack build failed with ${topLevelErrors.length} errors:\n${topLevelErrors.join("\n")}`);
66
+ if (topLevelErrors.size !== 0) {
67
+ throw new Error(`Utoopack build failed with ${topLevelErrors.size} errors:\n${[...topLevelErrors].join("\n")}`);
66
68
  }
67
69
  }
68
70
  function isRelevantWarning(issue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack-shared",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [