Skip to content

Commit

Permalink
fix(refactor): builder-util-runtime, separate newError to eliminate c…
Browse files Browse the repository at this point in the history
…ircular dependency (#8251)
  • Loading branch information
m59peacemaker authored Jun 8, 2024
1 parent 13e0e0d commit 140e2f0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-jars-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"builder-util-runtime": patch
---

Refactored to resolve circular dependency, eliminating warnings from tools such as Rollup
5 changes: 5 additions & 0 deletions packages/builder-util-runtime/src/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function newError(message: string, code: string) {
const error = new Error(message)
;(error as NodeJS.ErrnoException).code = code
return error
}
2 changes: 1 addition & 1 deletion packages/builder-util-runtime/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Socket } from "net"
import { Transform } from "stream"
import { URL } from "url"
import { CancellationToken } from "./CancellationToken"
import { newError } from "./index"
import { newError } from "./error"
import { ProgressCallbackTransform, ProgressInfo } from "./ProgressCallbackTransform"

const debug = _debug("electron-builder")
Expand Down
7 changes: 1 addition & 6 deletions packages/builder-util-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export { UUID } from "./uuid"
export { ProgressCallbackTransform, ProgressInfo } from "./ProgressCallbackTransform"
export { parseXml, XElement } from "./xml"
export { BlockMap } from "./blockMapApi"
export { newError } from "./error"

// nsis
export const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe"
Expand All @@ -50,9 +51,3 @@ export function asArray<T>(v: null | undefined | T | Array<T>): Array<T> {
return [v]
}
}

export function newError(message: string, code: string) {
const error = new Error(message)
;(error as NodeJS.ErrnoException).code = code
return error
}
2 changes: 1 addition & 1 deletion packages/builder-util-runtime/src/uuid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createHash, randomBytes } from "crypto"
import { newError } from "./index"
import { newError } from "./error"

const invalidName = "options.name must be either a string or a Buffer"

Expand Down
2 changes: 1 addition & 1 deletion packages/builder-util-runtime/src/xml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as sax from "sax"
import { newError } from "./index"
import { newError } from "./error"

export class XElement {
value = ""
Expand Down

0 comments on commit 140e2f0

Please sign in to comment.