-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak documentation for nickel_lang_utilities::project_root
- Loading branch information
Showing
1 changed file
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
use std::path::PathBuf; | ||
|
||
/// NOTE: this is a workaround for the lack of a CARGO_WORKSPACE_DIR | ||
/// environment variable, as suggested [here](https://github.com/rust-lang/cargo/issues/3946#issuecomment-1433384192). | ||
/// A better workaround might be to set this in the `[env]` section | ||
/// of `.cargo/config.toml`, as suggested[here](https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993) | ||
/// but we currently don't check that file in, and I'm not sure | ||
/// whether doing so is a good idea. | ||
/// Return a [`PathBuf`] pointing to the workspace root of Nickel repository. For example, use | ||
/// ```rust | ||
/// # use nickel_lang_utilities::project_root::project_root; | ||
/// # use std::path::PathBuf; | ||
/// let readme = project_root().join("README.md"); | ||
/// # assert_eq!(readme, PathBuf::from(&concat!(env!("CARGO_MANIFEST_DIR"), "/../README.md"))) | ||
/// ``` | ||
/// | ||
/// This is a workaround for the lack of a CARGO_WORKSPACE_DIR | ||
/// environment variable, as suggested [here](https://github.com/rust-lang/cargo/issues/3946#issuecomment-1433384192). | ||
/// A better workaround might be to set this in the `[env]` section | ||
/// of `.cargo/config.toml`, as suggested[here](https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993) | ||
/// but we currently don't check that file in, and I'm not sure | ||
/// whether doing so is a good idea. | ||
pub fn project_root() -> PathBuf { | ||
PathBuf::from(&concat!(env!("CARGO_MANIFEST_DIR"), "/..")) | ||
} |