Skip to content

Commit

Permalink
chore(cli): Use runtime SILE_PATH if set, then fall back to buildtime…
Browse files Browse the repository at this point in the history
… one
  • Loading branch information
alerque committed Sep 12, 2023
1 parent 8a8b506 commit c437b38
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use mlua::chunk;
use mlua::prelude::*;
use std::path::PathBuf;
use std::{env, path::PathBuf};
#[cfg(feature = "cli")]
pub mod cli;

pub type Result<T> = anyhow::Result<T>;

pub fn version() -> crate::Result<String> {
let lua = unsafe { Lua::unsafe_new() };
let sile_path: LuaString = lua.create_string(env!("SILE_PATH"))?;
let sile_path = match env::var("SILE_PATH") {
Ok(val) => val,
Err(_) => env!("SILE_PATH").to_string(),
};
let sile_path: LuaString = lua.create_string(&sile_path)?;
let sile: LuaTable = lua
.load(chunk! {
local status = pcall(dofile, $sile_path .. "/core/pathsetup.lua")
Expand Down Expand Up @@ -43,7 +47,11 @@ pub fn run(
traceback: bool,
) -> crate::Result<()> {
let lua = unsafe { Lua::unsafe_new() };
let sile_path: LuaString = lua.create_string(env!("SILE_PATH"))?;
let sile_path = match env::var("SILE_PATH") {
Ok(val) => val,
Err(_) => env!("SILE_PATH").to_string(),
};
let sile_path: LuaString = lua.create_string(&sile_path)?;
let sile: LuaTable = lua
.load(chunk! {
local status = pcall(dofile, $sile_path .. "/core/pathsetup.lua")
Expand Down

0 comments on commit c437b38

Please sign in to comment.