|
|
@ -22,20 +22,25 @@ pub struct ExecBuilder {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ExecBuilder {
|
|
|
|
impl ExecBuilder {
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "trace")]
|
|
|
|
pub fn create(
|
|
|
|
pub fn create(
|
|
|
|
script: PathBuf,
|
|
|
|
script: PathBuf,
|
|
|
|
os_config: OSConfig,
|
|
|
|
os_config: OSConfig,
|
|
|
|
task_config: embed_nu::Value,
|
|
|
|
task_config: embed_nu::Value,
|
|
|
|
distro_config: &DistroConfig,
|
|
|
|
distro_config: &DistroConfig,
|
|
|
|
) -> Result<Self> {
|
|
|
|
) -> Result<Self> {
|
|
|
|
|
|
|
|
tracing::debug!("Loading script {script:?}...");
|
|
|
|
let script_contents = Self::get_script_contents(&script)?;
|
|
|
|
let script_contents = Self::get_script_contents(&script)?;
|
|
|
|
let mut common_scripts = String::new();
|
|
|
|
let mut common_scripts = String::new();
|
|
|
|
|
|
|
|
|
|
|
|
for script in &distro_config.config.include_scripts {
|
|
|
|
for script in &distro_config.config.include_scripts {
|
|
|
|
|
|
|
|
tracing::debug!("Loading include script {script:?}...");
|
|
|
|
common_scripts.push_str("\n");
|
|
|
|
common_scripts.push_str("\n");
|
|
|
|
common_scripts.push_str(&Self::get_script_contents(&script)?);
|
|
|
|
common_scripts.push_str(&Self::get_script_contents(&script)?);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tracing::debug!("Building context...");
|
|
|
|
|
|
|
|
|
|
|
|
let mut ctx = embed_nu::Context::builder()
|
|
|
|
let mut ctx = embed_nu::Context::builder()
|
|
|
|
.with_command_groups(CommandGroupConfig::default().all_groups(true))?
|
|
|
|
.with_command_groups(CommandGroupConfig::default().all_groups(true))?
|
|
|
|
.add_command(RunCommand)?
|
|
|
|
.add_command(RunCommand)?
|
|
|
@ -56,6 +61,7 @@ impl ExecBuilder {
|
|
|
|
.add_script(common_scripts)?
|
|
|
|
.add_script(common_scripts)?
|
|
|
|
.add_script(script_contents)?
|
|
|
|
.add_script(script_contents)?
|
|
|
|
.build()?;
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
|
|
|
|
if !ctx.has_fn("main") {
|
|
|
|
if !ctx.has_fn("main") {
|
|
|
|
Err(ScriptError::MissingMain(script).into())
|
|
|
|
Err(ScriptError::MissingMain(script).into())
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|