From f4c8295519ceb657adf912ba5cf4303404594957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Sun, 13 Feb 2022 09:53:28 +0100 Subject: [PATCH] chore: allow overriding the completions output directory --- build.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index a8b0677..bc8e13d 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -use std::{env, fs::create_dir_all, path::Path}; +use std::{env, fs::create_dir_all}; use clap::{ArgEnum, IntoApp}; use clap_complete::{generate_to, Shell}; @@ -12,7 +12,11 @@ fn main() { return; } - let out = &Path::new(&env::var_os("OUT_DIR").unwrap()).join("completions"); + let out = &env::var_os("OUCH_COMPLETIONS_DIR") + .map(|path| PathBuf::from(&path)) + .or_else(|| env::var_os("OUT_DIR").map(|path| PathBuf::from(&path)).map(|path| path.join("completions"))) + .unwrap(); + create_dir_all(out).unwrap(); let app = &mut Opts::into_app();