Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/moody-radios-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cloudflared": patch
---

Make `bin` respect `process.env.CLOUDFLARED_BIN` before choosing the default path, and it can be changed later using `use`.
20 changes: 16 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import path from "node:path";

/**
* The path to the cloudflared binary.
*/
export const bin = path.join(
export const DEFAULT_CLOUDFLARED_BIN = path.join(
__dirname,
"..",
"bin",
process.platform === "win32" ? "cloudflared.exe" : "cloudflared",
);

/**
* The path to the cloudflared binary.
* If the `CLOUDFLARED_BIN` environment variable is set, it will be used; otherwise, {@link DEFAULT_CLOUDFLARED_BIN} will be used.
* Can be overridden with {@link use}.
*/
export let bin = process.env.CLOUDFLARED_BIN || DEFAULT_CLOUDFLARED_BIN;

/**
* Override the path to the cloudflared binary.
* @param executable - The path to the cloudflared executable.
*/
export function use(executable: string): void {
bin = executable;
}

export const CLOUDFLARED_VERSION = process.env.CLOUDFLARED_VERSION || "latest";

export const RELEASE_BASE = "https://github.com/cloudflare/cloudflared/releases/";