Skip to main content

vs_shell/
lib.rs

1//! Shell activation and path helpers for `vs`.
2
3mod activate;
4mod env;
5mod link;
6mod path;
7
8use thiserror::Error;
9
10pub use activate::{ShellKind, render_activation};
11pub use env::EnvDelta;
12pub use link::{link_directory, remove_existing};
13pub use path::{HomePaths, bin_dir, global_current_dir, home_paths, install_dir, project_sdk_dir};
14
15/// Errors returned by shell utilities.
16#[derive(Debug, Error)]
17pub enum ShellError {
18    /// An I/O operation failed.
19    #[error(transparent)]
20    Io(#[from] std::io::Error),
21    /// The shell name is unsupported.
22    #[error("unknown shell: {0}")]
23    UnknownShell(String),
24}
25
26#[cfg(test)]
27mod tests {
28    use super::{ShellKind, render_activation};
29
30    #[test]
31    fn activation_script_should_reference_hidden_hook_command() {
32        let script = render_activation(ShellKind::Bash);
33        assert!(script.contains("vs __hook-env bash"));
34        assert!(script.contains("VS_SESSION_ID"));
35    }
36
37    #[test]
38    fn nushell_activation_should_handle_unset_markers() {
39        let script = render_activation(ShellKind::Nushell);
40        assert!(script.contains("__VS_UNSET"));
41        assert!(script.contains("hide-env"));
42    }
43}