From 92a69f5f2409632e995534d953961c4eeb14e53e Mon Sep 17 00:00:00 2001 From: Nor Khasyatillah Date: Thu, 22 Aug 2024 18:30:31 +0700 Subject: [PATCH] update build.rs --- build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index d80e9ed..61e5aec 100644 --- a/build.rs +++ b/build.rs @@ -5,9 +5,11 @@ include!("src/cli.rs"); fn main() -> Result<(), clap::Error> { use clap::CommandFactory; use clap_complete::{generate_to, Shell}; - use std::{env, fs, path}; + use std::{fs, path, process::exit}; - let out_dir = env!("OUT_DIR"); + let out_dir = option_env!("OUT_DIR").unwrap_or_else(|| { + exit(0); + }); let dir = path::Path::new(&out_dir).join("completions/"); if !dir.exists() { fs::create_dir(dir.clone()).expect("Failed to create 'completions' directory.");