Skip to content

Commit 5a9857e

Browse files
authored
Extract env var name
1 parent d8160a6 commit 5a9857e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/bot/src/worker.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,14 @@ struct Process {
120120

121121
impl Process {
122122
async fn spawn() -> anyhow::Result<Self> {
123-
let worker_path = std::env::var_os("TYPST_BOT_WORKER_PATH").unwrap_or_else(|| "./worker".into());
123+
const VAR_NAME: &str = "TYPST_BOT_WORKER_PATH";
124+
let worker_path = std::env::var_os(VAR_NAME).unwrap_or_else(|| "./worker".into());
124125
let child = std::process::Command::new(&worker_path)
125126
.stdin(Stdio::piped())
126127
.stdout(Stdio::piped())
127128
.stderr(Stdio::inherit())
128129
.spawn()
129-
.with_context(|| format!("spawning worker process (path={worker_path:?}).\n\ntry setting TYPST_BOT_WORKER_PATH to point to the worker binary, e.g. in the cargo target directory. alternatively, follow the instructions in the README that describe how to set up a standalone installation.")?;
130+
.with_context(|| format!("spawning worker process (path={worker_path:?}).\n\ntry setting the env var {VAR_NAME} to point to the worker binary, e.g. in the cargo target directory. alternatively, follow the instructions in the README that describe how to set up a standalone installation.")?;
130131

131132
let mut ret = Self { child: Some(child) };
132133
// Ask for the version and ignore it, as a health check.

0 commit comments

Comments
 (0)