From 6fe5e2d75257504f0321e2e98b6fb675b716fe25 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 12 Aug 2022 18:28:45 +0300 Subject: feat(tvix/eval): resolve relative path literals Resolves relative paths (e.g. `./foo`) either relative to the location of the Nix file, or relative to the working directory if none is supplied. Change-Id: I70ec574657b221b458015117a004b6e4a9c25a30 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6185 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/main.rs') diff --git a/tvix/eval/src/main.rs b/tvix/eval/src/main.rs index 0c4d082783..3d0c29688e 100644 --- a/tvix/eval/src/main.rs +++ b/tvix/eval/src/main.rs @@ -1,4 +1,8 @@ -use std::{env, fs, path::PathBuf, process}; +use std::{ + env, fs, + path::{Path, PathBuf}, + process, +}; use rustyline::{error::ReadlineError, Editor}; @@ -18,8 +22,9 @@ fn main() { fn run_file(file: &str) { let contents = fs::read_to_string(file).expect("failed to read the input file"); + let path = Path::new(file).to_owned(); - match tvix_eval::interpret(&contents) { + match tvix_eval::interpret(&contents, Some(path)) { Ok(result) => println!("=> {} :: {}", result, result.type_of()), Err(err) => eprintln!("{}", err), } @@ -53,7 +58,7 @@ fn run_prompt() { continue; } - match tvix_eval::interpret(&line) { + match tvix_eval::interpret(&line, None) { Ok(result) => { println!("=> {} :: {}", result, result.type_of()); rl.add_history_entry(line); -- cgit 1.4.1