Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/fspy_shared_unix/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ impl Exec {
///
/// * `Ok(())` if resolution succeeds and `self` is updated with resolved paths
/// * `Err(nix::Error)` with appropriate errno, like the exec function would return
///
/// # Errors
///
/// Returns an error if:
/// - The program is not found in PATH (`ENOENT`)
/// - The program file cannot be accessed or read (`EACCES`, `EISDIR`, `EIO`)
/// - Shebang parsing fails due to I/O errors (`EIO`)
pub fn resolve(
&mut self,
mut on_path_access: impl FnMut(PathAccess<'_>),
Expand Down Expand Up @@ -134,6 +141,14 @@ impl Exec {
}
}

/// Ensures an environment variable is set to the specified value
///
/// If the variable doesn't exist, it is added. If it exists with the same value,
/// no change is made. If it exists with a different value, an error is returned.
///
/// # Errors
///
/// Returns `Err(nix::Error::EINVAL)` if the environment variable already exists with a different value.
pub fn ensure_env(
envs: &mut Vec<(BString, Option<BString>)>,
name: impl AsRef<BStr>,
Expand Down
8 changes: 8 additions & 0 deletions crates/fspy_shared_unix/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub fn encode_payload(payload: Payload) -> EncodedPayload {
EncodedPayload { payload, encoded_string: encoded_string.into() }
}

/// Decodes the fspy payload from the environment variable
///
/// # Errors
///
/// Returns an error if:
/// - The environment variable is not found
/// - The base64 decoding fails
/// - The bincode deserialization fails
pub fn decode_payload_from_env() -> anyhow::Result<EncodedPayload> {
let Some(encoded_string) = std::env::var_os(PAYLOAD_ENV_NAME) else {
anyhow::bail!("Environment variable '{}' not found", PAYLOAD_ENV_NAME);
Expand Down
5 changes: 5 additions & 0 deletions crates/fspy_shared_unix/src/spawn/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ use crate::{

pub struct PreExec(Infallible);
impl PreExec {
/// Runs pre-exec operations
///
/// # Errors
///
/// This function never returns an error as the type is `Infallible`
Comment thread
Brooooooklyn marked this conversation as resolved.
pub fn run(&self) -> nix::Result<()> {
match self.0 {}
}
Expand Down
11 changes: 11 additions & 0 deletions crates/fspy_shared_unix/src/spawn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ use crate::{
payload::EncodedPayload,
};

/// Handles exec command resolution and injection
///
/// Resolves the program path and prepares the command for execution with
/// appropriate environment variables and hooks.
///
/// # Errors
///
/// Returns an error if:
/// - Program resolution fails (see [`Exec::resolve`] error variants, such as `ENOENT` (file not found) or `EACCES` (permission denied))
/// - Environment variable operations fail (e.g., `ensure_env` may return `EINVAL` if an existing value conflicts)
Comment thread
Brooooooklyn marked this conversation as resolved.
/// - Platform-specific errors from `os_specific::handle_exec`
pub fn handle_exec(
command: &mut Exec,
config: ExecResolveConfig,
Expand Down
4 changes: 2 additions & 2 deletions crates/vite_task/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ impl std::fmt::Debug for ResolvedTaskCommand {
///
/// # Fingerprint Ignores Impact on Cache
///
/// The `fingerprint_ignores` field controls which files are tracked in PostRunFingerprint:
/// The `fingerprint_ignores` field controls which files are tracked in `PostRunFingerprint`:
/// - Changes to this config must invalidate the cache
/// - Vec maintains insertion order (pattern order matters for last-match-wins semantics)
/// - Even though ignore patterns only affect PostRunFingerprint, the config itself is part of the cache key
/// - Even though ignore patterns only affect `PostRunFingerprint`, the config itself is part of the cache key
#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)]
#[diff(attr(#[derive(Debug)]))]
pub struct CommandFingerprint {
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_task/src/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl PostRunFingerprint {
.par_iter()
.filter(|(path, _)| {
// Filter out paths that match ignore patterns
ignore_matcher.as_ref().map_or(true, |matcher| !matcher.is_match(path))
ignore_matcher.as_ref().is_none_or(|matcher| !matcher.is_match(path))
Comment thread
Brooooooklyn marked this conversation as resolved.
})
.flat_map(|(path, path_read)| {
Some((|| {
Expand Down
Loading