feat(tvix/eval): Implement builtins.pathExists
Change-Id: Ife8a690e9036868964771893ab29a9ae3a2d2365 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6919 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									273ba73754
								
							
						
					
					
						commit
						0b8a967aca
					
				
					 3 changed files with 10 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -15,10 +15,11 @@ use crate::{
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
fn impure_builtins() -> Vec<Builtin> {
 | 
			
		||||
    vec![Builtin::new(
 | 
			
		||||
        "readDir",
 | 
			
		||||
        &[true],
 | 
			
		||||
        |args: Vec<Value>, vm: &mut VM| {
 | 
			
		||||
    vec![
 | 
			
		||||
        Builtin::new("pathExists", &[true], |args: Vec<Value>, vm: &mut VM| {
 | 
			
		||||
            Ok(super::coerce_value_to_path(&args[0], vm)?.exists().into())
 | 
			
		||||
        }),
 | 
			
		||||
        Builtin::new("readDir", &[true], |args: Vec<Value>, vm: &mut VM| {
 | 
			
		||||
            let path = super::coerce_value_to_path(&args[0], vm)?;
 | 
			
		||||
            let mk_err = |err: io::Error| ErrorKind::IO {
 | 
			
		||||
                path: Some(path.clone()),
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +51,8 @@ fn impure_builtins() -> Vec<Builtin> {
 | 
			
		|||
                );
 | 
			
		||||
            }
 | 
			
		||||
            Ok(Value::attrs(NixAttrs::from_map(res)))
 | 
			
		||||
        },
 | 
			
		||||
    )]
 | 
			
		||||
        }),
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Return all impure builtins, that is all builtins which may perform I/O
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue